Re: [External] RE: [PATCH] EDAC/skx_common: Fix allocation check when adxl_component_count is 0
From: Rui Qi
Date: Mon Sep 22 2025 - 02:22:01 EST
On 9/19/25 8:56 PM, Zhuo, Qiuxu wrote:
> 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().
>
Well, I've rechecked the code, and your statement is correct. So my
modification is indeed unnecessary.
>>
>> Signed-off-by: Rui Qi <qirui.001@xxxxxxxxxxxxx>
>> [...]