ice: Add check for kzalloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 8 Dec 2022 13:35:52 +0000 (21:35 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:58:27 +0000 (11:58 +0100)
commit96a9873188552ebb2afe76033d7329a5ecabef6e
treea2464152f8b2bc9d38ab3c656c234e436cf97199
parent500ca1da9d0876244eb4d1b0ece6fa0e9968d45d
ice: Add check for kzalloc

[ Upstream commit 40543b3d9d2c13227ecd3aa90a713c201d1d7f09 ]

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@iscas.ac.cn>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/intel/ice/ice_gnss.c