RE: [Intel-wired-lan] [PATCH net v4] ice: Add check for kzalloc

From: G, GurucharanX
Date: Thu Jan 05 2023 - 00:52:25 EST




> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@xxxxxxxxxx> On Behalf Of
> Jiasheng Jiang
> Sent: Thursday, December 8, 2022 7:06 PM
> To: jiri@xxxxxxxxxxx
> Cc: leon@xxxxxxxxxx; intel-wired-lan@xxxxxxxxxxxxxxxx; Jiasheng Jiang
> <jiasheng@xxxxxxxxxxx>; Brandeburg, Jesse <jesse.brandeburg@xxxxxxxxx>;
> linux-kernel@xxxxxxxxxxxxxxx; edumazet@xxxxxxxxxx; Nguyen, Anthony L
> <anthony.l.nguyen@xxxxxxxxx>; netdev@xxxxxxxxxxxxxxx; kuba@xxxxxxxxxx;
> pabeni@xxxxxxxxxx; davem@xxxxxxxxxxxxx
> Subject: [Intel-wired-lan] [PATCH net v4] ice: Add check for kzalloc
>
> Add the check for the return value of kzalloc in order to avoid NULL pointer
> dereference.
> Moreover, use the goto-label to share the clean code.
>
> Fixes: d6b98c8d242a ("ice: add write functionality for GNSS TTY")
> Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
> ---
> Changelog:
>
> v3 -> v4:
>
> 1. Move the check right after the kzalloc.
>
> v2 -> v3:
>
> 1. Use "while (i--)" to simplify the code.
>
> v1 -> v2:
>
> 1. Use goto-label to share the clean code.
> ---
> drivers/net/ethernet/intel/ice/ice_gnss.c | 23 ++++++++++++++---------
> 1 file changed, 14 insertions(+), 9 deletions(-)
>

Tested-by: Gurucharan G <gurucharanx.g@xxxxxxxxx> (A Contingent worker at Intel)