RE: [PATCH] EDAC/skx_common: Fix allocation check when adxl_component_count is 0

From: Zhuo, Qiuxu

Date: Fri Sep 19 2025 - 08:56:46 EST


Hi Rui Qi,

Thanks for looking at the code.

> From: Rui Qi <qirui.001@xxxxxxxxxxxxx>
> [...]
> Subject: [PATCH] EDAC/skx_common: Fix allocation check when
> adxl_component_count is 0
>
> From: Rui Qi <qirui.001@xxxxxxxxxxxxx>
>
> Use ZERO_OR_NULL_PTR instead of simple NULL check to properly handle the
> case where adxl_component_count is 0, which would result in kcalloc
> returning ZERO_SIZE_PTR rather than NULL.
>
> This ensures correct error handling when no ADXL components are present
> and prevents potential issues with zero-sized allocations.

If the ADXL component names are empty, skx_adxl_get() will immediately jump to error handling.
So, the adxl_component_count value is guaranteed to be non-zero when passed to kcalloc().

>
> Signed-off-by: Rui Qi <qirui.001@xxxxxxxxxxxxx>
> [...]