]> 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>
Thu, 3 Jul 2025 09:52:32 +0000 (17:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 1 Aug 2025 08:48:43 +0000 (09:48 +0100)
commit 4ff12d82dac119b4b99b5a78b5af3bf2474c0a36 upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/intel/ice/ice_ddp.c

index 272fd823a825d0f2796ff6677c91e41133d4172d..e4c8cd12a41d13f5b3f6ae488f7d42ed2873d2f4 100644 (file)
@@ -2277,6 +2277,8 @@ enum ice_ddp_state ice_copy_and_init_pkg(struct ice_hw *hw, const u8 *buf,
                return ICE_DDP_PKG_ERR;
 
        buf_copy = devm_kmemdup(ice_hw_to_dev(hw), buf, len, GFP_KERNEL);
+       if (!buf_copy)
+               return ICE_DDP_PKG_ERR;
 
        state = ice_init_pkg(hw, buf_copy, len);
        if (!ice_is_init_pkg_successful(state)) {