From patchwork Tue Dec 12 02:40:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kunwu Chan X-Patchwork-Id: 177052 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp7473814vqy; Mon, 11 Dec 2023 18:41:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IE6g1jFDY3H8Lf/EqUybZ9qZXfdN2CLQgFOvyWDTYaKdKDCtE7fj/acxCWldNoH/88pX6KZ X-Received: by 2002:a05:6808:1493:b0:3b9:d4c0:5fac with SMTP id e19-20020a056808149300b003b9d4c05facmr7261582oiw.22.1702348909799; Mon, 11 Dec 2023 18:41:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702348909; cv=none; d=google.com; s=arc-20160816; b=jCuyvF+vHznUu3SWkB7kn0kI6FVHD8Ki91WLlbOL0/oXLEGsMYuzy3tqWDvSbIvbM1 oOmSp1dpX38orMYrpuz0fZh2iuNfUzL4G2VTvE9N+c484uYPaNkpt7ahUw+5bFpz9RCE rK4QF5JaD2Zk0nAoM0O0YU52RUN9puh7NGT9ESBasiMA/xijEHKdbNz+npHxkCCKHHhO vOEDxINgnsVvrVntFaDnUfdej7E3wsW03L2xb/Vu0+oPz+AuWBPRUn7ErjI8ShL/96VI Mpajrln/oH1M3pUwdPWTt4ixQCqkxOZHt+48psbVaSqOAOFHokz1xP9hFth51xdmamar YoVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=ClQm7TMg1QtULVZBJp3IluzjYfaMQlj9xvz//FC/YEA=; fh=mxdIi1UagyzNWwtTL9nf2TVBF4+jojfbudp7+wRChsM=; b=mPYlNY9+LRD0hKD1QDX2cSOhfPLSLYH8Dbcpkl2g8lH0gBoUp/XAdIeO62bjhGCHQl T2tN7jR1KQftAtphG9Mtd0gGsQCDVS+s1ZnZbQFxaXQ/4FdJGsy4zZ0HUnJKKyFVANQ+ JDKLRtsO99PsriaqAwcJVmIJfZzmaCnPEh5Pz83g+GtNhUmEMN+dlqMJM7eT/0MuMk2S MoDJ5lIUtPAE1enp1YMgnxIV8p3iGoPn7BdfoLchCPCpRi4A6l4rQNKT8YDgvSot4Yhx ehVHyiK8xL0NrKQ5F+FWb7ix2OidBP91jHQX7Y4g4AnrZHRy99nYsSu7HWaZk74VH/Fg G1DA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id r4-20020a6560c4000000b005b90af1943asi6884507pgv.807.2023.12.11.18.41.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 18:41:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B000C80C6197; Mon, 11 Dec 2023 18:41:42 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231131AbjLLCle (ORCPT + 99 others); Mon, 11 Dec 2023 21:41:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229587AbjLLCld (ORCPT ); Mon, 11 Dec 2023 21:41:33 -0500 Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A37395; Mon, 11 Dec 2023 18:41:37 -0800 (PST) X-UUID: 4759270ba271402a9eb2763b09177321-20231212 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.33,REQID:ef34a73b-103f-49bd-8d1b-2c1247446e59,IP:15, URL:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACT ION:release,TS:-5 X-CID-INFO: VERSION:1.1.33,REQID:ef34a73b-103f-49bd-8d1b-2c1247446e59,IP:15,UR L:0,TC:0,Content:-5,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-5 X-CID-META: VersionHash:364b77b,CLOUDID:32091661-c89d-4129-91cb-8ebfae4653fc,B ulkID:231212104122Y4L22WMT,BulkQuantity:0,Recheck:0,SF:44|66|38|24|17|19|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_FAS,TF_CID_SPAM_FSD,TF_CID_SPAM_FSI X-UUID: 4759270ba271402a9eb2763b09177321-20231212 X-User: chentao@kylinos.cn Received: from vt.. [(116.128.244.169)] by mailgw (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1486382473; Tue, 12 Dec 2023 10:41:20 +0800 From: Kunwu Chan To: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, richardcochran@gmail.com, jacob.e.keller@intel.com Cc: karol.kolacinski@intel.com, michal.michalik@intel.com, intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan , Kunwu Chan , Przemek Kitszel Subject: [PATCH v2 iwl-next] ice: Fix some null pointer dereference issues in ice_ptp.c Date: Tue, 12 Dec 2023 10:40:15 +0800 Message-Id: <20231212024015.11595-1-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 11 Dec 2023 18:41:42 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785042210641304231 X-GMAIL-MSGID: 1785042210641304231 devm_kasprintf() returns a pointer to dynamically allocated memory which can be NULL upon failure. Fixes: d938a8cca88a ("ice: Auxbus devices & driver for E822 TS") Cc: Kunwu Chan Suggested-by: Przemek Kitszel Signed-off-by: Kunwu Chan Reviewed-by: Przemek Kitszel Reviewed-by: Simon Horman Tested-by: Pucha Himasekhar Reddy (A Contingent worker at Intel) --- drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c index e9e59f4b5580..848e3e063e64 100644 --- a/drivers/net/ethernet/intel/ice/ice_ptp.c +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c @@ -2743,6 +2743,8 @@ static int ice_ptp_register_auxbus_driver(struct ice_pf *pf) name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), ice_get_ptp_src_clock_index(&pf->hw)); + if (!name) + return -ENOMEM; aux_driver->name = name; aux_driver->shutdown = ice_ptp_auxbus_shutdown; @@ -2989,6 +2991,8 @@ static int ice_ptp_create_auxbus_device(struct ice_pf *pf) name = devm_kasprintf(dev, GFP_KERNEL, "ptp_aux_dev_%u_%u_clk%u", pf->pdev->bus->number, PCI_SLOT(pf->pdev->devfn), ice_get_ptp_src_clock_index(&pf->hw)); + if (!name) + return -ENOMEM; aux_dev->name = name; aux_dev->id = id;