]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ice: Fix a null pointer dereference in ice_copy_and_init_pkg()
authorHaoxiang Li <haoxiang_li2024@163.com>
Tue, 29 Jul 2025 19:25:14 +0000 (15:25 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Aug 2025 14:22:53 +0000 (16:22 +0200)
[ Upstream commit 4ff12d82dac119b4b99b5a78b5af3bf2474c0a36 ]

Add check for the return value of devm_kmemdup()
to prevent potential null pointer dereference.

Fixes: c76488109616 ("ice: Implement Dynamic Device Personalization (DDP) download")
Cc: stable@vger.kernel.org
Signed-off-by: Haoxiang Li <haoxiang_li2024@163.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Rinitha S <sx.rinitha@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
[ applied the patch to ice_flex_pipe.c instead of ice_ddp.c ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/intel/ice/ice_flex_pipe.c

index a81be917f6538fc48b2e76e3b6d595415e71170c..da2906720c63e52e1ad25672988b2782e3bb6d50 100644 (file)
@@ -1449,6 +1449,8 @@ enum ice_status ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf, u32 len)
                return ICE_ERR_PARAM;
 
        buf_copy = devm_kmemdup(ice_hw_to_dev(hw), buf, len, GFP_KERNEL);
+       if (!buf_copy)
+               return ICE_ERR_NO_MEMORY;
 
        status = ice_init_pkg(hw, buf_copy, len);
        if (status) {