From patchwork Mon Oct 23 06:45:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Ni X-Patchwork-Id: 737791 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CEDDCDB474 for ; Mon, 23 Oct 2023 06:53:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229548AbjJWGxL (ORCPT ); Mon, 23 Oct 2023 02:53:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjJWGxK (ORCPT ); Mon, 23 Oct 2023 02:53:10 -0400 X-Greylist: delayed 448 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Sun, 22 Oct 2023 23:53:08 PDT Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E9F79B0 for ; Sun, 22 Oct 2023 23:53:08 -0700 (PDT) Received: from localhost (unknown [124.16.138.129]) by APP-01 (Coremail) with SMTP id qwCowAA3Px_iFTZl2bVyAA--.45S2; Mon, 23 Oct 2023 14:42:42 +0800 (CST) From: Chen Ni To: gregory.greenman@intel.com, kvalo@kernel.org, johannes.berg@intel.com, mukesh.sisodiya@intel.com Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Ni Subject: [PATCH] wifi: iwlwifi: Add check for kmemdup Date: Mon, 23 Oct 2023 06:45:01 +0000 Message-Id: <20231023064501.274599-1-nichen@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: qwCowAA3Px_iFTZl2bVyAA--.45S2 X-Coremail-Antispam: 1UD129KBjvd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q/ Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Since the kmemdup may return NULL pointer, it should be better to add check for the return value in order to avoid NULL pointer dereference. Fixes: 5e31b3df86ec ("wifi: iwlwifi: dbg: print pc register data once fw dump occurred") Signed-off-by: Chen Ni --- drivers/net/wireless/intel/iwlwifi/iwl-drv.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c index 3d87d26845e7..9bba8fa62f54 100644 --- a/drivers/net/wireless/intel/iwlwifi/iwl-drv.c +++ b/drivers/net/wireless/intel/iwlwifi/iwl-drv.c @@ -1307,6 +1307,8 @@ static int iwl_parse_tlv_firmware(struct iwl_drv *drv, tlv_len / sizeof(struct iwl_pc_data); drv->trans->dbg.pc_data = kmemdup(tlv_data, tlv_len, GFP_KERNEL); + if (!drv->trans->dbg.pc_data) + return -ENOMEM; break; default: IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type);