Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3721291rdh; Tue, 28 Nov 2023 01:51:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IGOg2dpsF8e2DjAADFklMIlPhlvrZKh2IVU1pB88/UpT5+ky42NaKNShiqN1COYjk1ANV0W X-Received: by 2002:a17:902:820b:b0:1cf:cd4e:ca02 with SMTP id x11-20020a170902820b00b001cfcd4eca02mr6854504pln.24.1701165103878; Tue, 28 Nov 2023 01:51:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701165103; cv=none; d=google.com; s=arc-20160816; b=Y8ZSSzFsUdLgKfzKLlf2MyQkwf4mgtHbf0ChJ/oldXJTVUjeH4Zw1ilxYoUAZf+m8k 18AtUiwmMgb0z5poJIBo4INp4Jruc7ZlwjVuNr01/B4pO6oLv8JJj1GVHiKd2iYdiFot SEOkMdq9gRXp0svF9N3hKBGTjfVmW+H+VojsZ0+mG+/JMlQatM8rIyNICBfQf64tc9kW AFIwjOZOb+5XTBu/8qtCJBq9MIs4kaqv68LoBKq4K9L6rXCAN3fdVR+RanEiRV69POdQ tAn/tnJ8bZQz4OgubE6Bwe20nFi1dwDNNKmIXZG1lZXOmj04IA3dNceu5Y/y9VzG2JY+ 6yWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=zYhqQdNK3kk0ydHh8VBa4CBAVrPf4lsh3ws/WaPGjbU=; fh=T2SSeRfcjq/7qzpUHErgZoCuDQnIkEvkNRHpcIjhsiY=; b=bKg78gu27L6bHjcsKaxuOhOMOLWhm4wdrpF1xvNKYqqdUl2G5XYHm3JfzO/kWpiDDc BADeGtjcsLfJiHM4U89SxLJyB1Uo4+z95hODrHgoeLNVHk8Hq51FxrJP789UF/GKk2Sz L+lUfk0vfS03dKtIifZO0WraUY0HidBzIU5nPYryq3JIcp2H2GWm6VkpHYsGkYg554ay 1EkjV4cqJvYfq4vr+r0dm0ZCPGGyW3SB7/bKYuWQ+w51flQAeUXKRB6cjdHn/RoB9xJE bygLjOfGooosd0jDJFFrku2dZkfEcFEfSwoSWaDuMWtB1z507rKmk2aUm2ojKGoL0TFM ziPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LMZaj79Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id w13-20020a170902d3cd00b001cf8e4e84bbsi11008413plb.471.2023.11.28.01.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 01:51:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LMZaj79Y; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 06A998322722; Tue, 28 Nov 2023 01:51:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344010AbjK1JvZ (ORCPT + 99 others); Tue, 28 Nov 2023 04:51:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343999AbjK1JvY (ORCPT ); Tue, 28 Nov 2023 04:51:24 -0500 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 108E3109; Tue, 28 Nov 2023 01:51:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1701165092; x=1732701092; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=zLsHcMhIvU8wVZf2s893M6aCyB1ZsP/PLYWAFq1Nklw=; b=LMZaj79YFjFu6oWLZEIz+7QgLcqVC1Yh5V+BKXiskdtIhSHh3VfkiZzN uld+UOCetUUMJsmrqAuAUag7uGh8pEdu+8ssi4H7dMy6FR8fItNNKNkqz gXfDshxs3Rty6xGafE9IiAE1kYFgynmnWz/+OX+Lgcfs9KdRTiv24q4f6 iy1jsw8FvVimiPMtSA0FMWnS0aElQEqt3Iwo8DOQU0orROpYWkPbxbusG ooXViUvXP6LpgQ3kDBJSo2Dcdan69eS6QynpWUEeAQHW1qOYxSRKaXA06 XiRGiYU5cID8It9pXmHGWehIM0b32DNgaB/6PZKmPvRscIXLNB30zJOh5 g==; X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="373059739" X-IronPort-AV: E=Sophos;i="6.04,233,1695711600"; d="scan'208";a="373059739" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 01:51:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="1015861139" X-IronPort-AV: E=Sophos;i="6.04,233,1695711600"; d="scan'208";a="1015861139" Received: from haslam-mobl1.ger.corp.intel.com ([10.252.43.79]) by fmsmga006-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Nov 2023 01:51:19 -0800 Date: Tue, 28 Nov 2023 11:51:16 +0200 (EET) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Kunwu Chan cc: Hans de Goede , vadimp@nvidia.com, jiri@resnulli.us, shravankr@nvidia.com, kunwu.chan@hotmail.com, platform-driver-x86@vger.kernel.org, LKML Subject: Re: [PATCH] platform/mellanox: Add a null pointer check in mlxbf_pmc_create_groups In-Reply-To: <20231127063433.1549064-1-chentao@kylinos.cn> Message-ID: <5aa96a9-336a-d865-d6b9-3857ebe89db@linux.intel.com> References: <20231127063433.1549064-1-chentao@kylinos.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.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 (howler.vger.email [0.0.0.0]); Tue, 28 Nov 2023 01:51:41 -0800 (PST) On Mon, 27 Nov 2023, Kunwu Chan wrote: > devm_kasprintf() returns a pointer to dynamically allocated memory > which can be NULL upon failure. > > Fixes: 1a218d312e65 ("platform/mellanox: mlxbf-pmc: Add Mellanox BlueField PMC driver") > Signed-off-by: Kunwu Chan > --- > drivers/platform/mellanox/mlxbf-pmc.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/drivers/platform/mellanox/mlxbf-pmc.c b/drivers/platform/mellanox/mlxbf-pmc.c > index 0b427fc24a96..59bbe5e13f6b 100644 > --- a/drivers/platform/mellanox/mlxbf-pmc.c > +++ b/drivers/platform/mellanox/mlxbf-pmc.c > @@ -1882,6 +1882,8 @@ static int mlxbf_pmc_create_groups(struct device *dev, int blk_num) > pmc->block[blk_num].block_attr_grp.attrs = pmc->block[blk_num].block_attr; > pmc->block[blk_num].block_attr_grp.name = devm_kasprintf( > dev, GFP_KERNEL, pmc->block_name[blk_num]); > + if (!pmc->block[blk_num].block_attr_grp.name) > + return -ENOMEM; > pmc->groups[pmc->group_num] = &pmc->block[blk_num].block_attr_grp; > pmc->group_num++; I'm totally lost, why did you fix only one devm_kasprintf() location? Don't all of them need this check? -- i.