Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp568828pxb; Tue, 29 Mar 2022 07:51:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHHO+tnc/vg9aSIso42juCx/KoUsFQMNyrehvxJQGUZVUmc84Ag/dK91Ao18qPDbvawGhw X-Received: by 2002:a17:903:216:b0:156:1e8d:a81 with SMTP id r22-20020a170903021600b001561e8d0a81mr6414891plh.140.1648565468325; Tue, 29 Mar 2022 07:51:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1648565468; cv=pass; d=google.com; s=arc-20160816; b=WdaFoCYxHrYjQ6V5VVIMTxKP0bluYFi4GWCQDtEL/tW01Y/u+dzYyCSJAFxGdJL9+7 pqL1pc6CfbKHiKTDovh36mhjlwXzgGJSR+BsXYM8Pqi/sSUGGC53GBB4M1xSL3m1vlht T0nXuXM7tqiQTqFl+NdD27jRfpdBBs7MkwrxbXORvGuNuKZUW+BkDy51MMr87O0NcC8U X1DpeHU1zDRGnLWxqEpu/vp8J2v+GU/wBim2+Z1JwvGy1d48WzNplFdFr9BDz0IsClDY gC3aZqgOpndjOddW/hr6SyfzLLLbydcuC7PyftucZDlHmLtg2Gltld7TsmxPetvSsNmG u4hQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :content-id:content-language:accept-language:in-reply-to:references :message-id:date:thread-index:thread-topic:subject:cc:to:from :dkim-signature; bh=jh9Ztu8uxXSY13Jsw2eXfD8PTcbhjLbiD5lDBMYJIpg=; b=QWHAkA0YaafTI0VEGIX0py+3XCoR3BbAucukoyHuCWzCwVjdSbwXg1/sPp9j7ICmdH e3A1l3n1SaNfgwWtIqyRvT+ulC1WfakSdkz0u3p61u6J34OP7CNwb66PxtmsUussVpay gMEwxshsfdd6lb6+PXZiBl58v4JH6AD4MOXcCfssF2rtUyqzLOs+cK77WOv7angTHjhm HE5V/RsY+0KMTjL4aWeLABkwdEXhBIz9FzXxWX1+DH/VBc26/GyvzRuW3OtT/3MemZhs lV/wValRdwCm66l9aoiU30n8ByoSVc6/2SL9M2IVLYU+vKJkWcQBnl/OzxP2ovL9LNrT 1qQw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ikqkbb9P; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s6-20020a170902b18600b00153b2d165aasi17547291plr.434.2022.03.29.07.50.52; Tue, 29 Mar 2022 07:51:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=ikqkbb9P; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234082AbiC2JUi (ORCPT + 99 others); Tue, 29 Mar 2022 05:20:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231853AbiC2JUg (ORCPT ); Tue, 29 Mar 2022 05:20:36 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80077.outbound.protection.outlook.com [40.107.8.77]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AF6C12627; Tue, 29 Mar 2022 02:18:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HMdjh5utQfl+8jZesoZHDKn+BpT2RjXdaTfSKf6pQ+pxF0h74tPri21BgCUlU5uT/QotXYEGttCNo2j1eldwSESwtgvR9aZ8XGump4H0CvfaCmm16qVs9udlFRs8PwpYkZDLJM7JztxZzPuOuMcCLfoVspqTemwMV7+bIDcMwnT6ldoESEVCf+92oujU+cUvRHW8vKCCoYaWUnxTMZEJhugpSF4+WE5szLhT19jZJPbQF1flSPiXaQnQuslzhG4IKT1QgilFxgP6GRzHk6X+g7ePw9HLsRyj1MYLZijk0tYY7PYOfzpy/IXYRCOcumqVUUmx7qNlUJphvF9vYueuIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=jh9Ztu8uxXSY13Jsw2eXfD8PTcbhjLbiD5lDBMYJIpg=; b=NQ9cysfD3HjQTp78SRlkOi2nEkpAqMlg7Hj8WsnvcNoW8qen6nibWt7MKVDugiOmkF0tnb7MQggD2ZCiGfNLDRURuDIahY1KyytmJGOvVGftw28xl2otiGyGCaOfLxGRY+dDi1sdcdJTyj1ONEoVmbebcZErJ20GkdVYbThpuxPfPmhLs3AZIl+1hK+vSMGLO5pJFmYO66yzHRCkjHRqAZYKUFTIZzt+8zZRuX0ALjghGRnNlsULjO5ar66Ad76lrZGH75D7z/mFSa8MkBp8Mztt5wswz8GreDBWUKSSPAoc1fomyMOCuiSBrZoUyLTal0VbYqA/wajqZZmCratWOA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jh9Ztu8uxXSY13Jsw2eXfD8PTcbhjLbiD5lDBMYJIpg=; b=ikqkbb9PKWfcCh6PNAjr3N3hD6gZYlaeYCCICr+suFpe/sD2ijyAzzsWB58V7WpdrmFygnNiKD3/P90GS/u6gr8KJJNZM5PfQnM3sDeHKofJYN6z+6vZMywUvabuHpJ5Tk1Cb4IiinLgEd4/XkRlkzI8903nEhDi9sGnCfpQTUQ= Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by DB9PR04MB8249.eurprd04.prod.outlook.com (2603:10a6:10:25c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5123.16; Tue, 29 Mar 2022 09:18:49 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::f090:8a7e:c1e1:3d8e]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::f090:8a7e:c1e1:3d8e%3]) with mapi id 15.20.5102.022; Tue, 29 Mar 2022 09:18:49 +0000 From: Vladimir Oltean To: Zheng Yongjun CC: "andrew@lunn.ch" , "vivien.didelot@gmail.com" , "f.fainelli@gmail.com" , "davem@davemloft.net" , "kuba@kernel.org" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Claudiu Manoil , "alexandre.belloni@bootlin.com" , "UNGLinuxDriver@microchip.com" Subject: Re: [PATCH v2] net: dsa: felix: fix possible NULL pointer dereference Thread-Topic: [PATCH v2] net: dsa: felix: fix possible NULL pointer dereference Thread-Index: AQHYQ0zySk/umKLd5UCso4wZA+nelazWFWQA Date: Tue, 29 Mar 2022 09:18:49 +0000 Message-ID: <20220329091848.tfzoszmvjp47jre5@skbuf> References: <20220329090800.130106-1-zhengyongjun3@huawei.com> In-Reply-To: <20220329090800.130106-1-zhengyongjun3@huawei.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: bb99f3a6-98d8-4012-e715-08da1165225e x-ms-traffictypediagnostic: DB9PR04MB8249:EE_ x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: 0WbiRytASD0TV0SAvFyVueR5+uCYwW2BQ53+L8XtRsBcaNTOPqIBKdxC3CDAJcfUFlrzO0uWOF+kLgJEZCYSiwiHR7ltWaucZc07DLN4Y1RyVIZBDMQ0RMesZ8jINmYR7VP7TV3HoFhrcJ+WSjT/batAeID06A0uBlwFfR9FGmni45eXC9DuJmCZy5OLrP75lgt0d9bFHe9FZ+qFK4JU41SALNw/1AuK3KwCdm7PKwQw/gaJ8HDZqbRpOUUyyFoX8t7PIWB5wRxIFeq0v62rVFCfrw7aotgB6JmBaqiHpfE3uQ/ixmpzIYKXOt5Sj6XQengji8Q/dM4/D2gsmUVi9S9EL/qF62qv6csX7UbdiXSkoU2WHNimXKLIH2aQPgiSm0Az5LtdpK/3eFMox+N6QG+Vhs8dD3IMYcxGS8Y9CbXE9cwUDBDI/wJBG9Vv8dIi7WC73esRz+rAwJQOOfLE4ttIUXOykGe5IZXLzGxvpW3TY11lZ/Y1j1RIcdGAVge4K0xvsJgnMbT/LgDETSgVcfDo0Fx07mnpCmUOtmyUNiUEA82snG+pAW/eRCRe0fapxEs609JHNTntXJKaLBw82PEmWYfj1QcUoGkUxiDpIp5L4gRfI2PKqv9xwgLZa3ixvZfflayY/IR099fNRFQtmt9ioxgjCetC+8U8DXHUJsU7c0mjmau8L0HKI+b/RtYSfb4hEv6ueeCZDC//vvKgvQ== x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(7916004)(366004)(6916009)(54906003)(83380400001)(316002)(38070700005)(38100700002)(1076003)(186003)(4326008)(76116006)(66946007)(66476007)(64756008)(26005)(66446008)(86362001)(71200400001)(8676002)(66556008)(33716001)(6486002)(508600001)(6512007)(9686003)(122000001)(6506007)(8936002)(5660300002)(7416002)(44832011)(2906002);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?wzrfyAudkwk+mxOwH16KszHqSFPoyJAbETfa7zf3JenhKvRzlUBk10DTdzpU?= =?us-ascii?Q?SGFKl5Wkj4Gcbqse55pTSfPRywuDNuehNmR3/dBf2oBHN7FPbif+HKt8xuJw?= =?us-ascii?Q?RPcd3yqDhwkKfhUasGEknAeYpkH3FJRKTzFzBokc30qMk0O8jpkCC7MG7fmL?= =?us-ascii?Q?VMjYu5lUc537D+hyGQE1DPVHhHGAML3xK7hLa1i7kVwfZpZ0uuUMOwv8bjEQ?= =?us-ascii?Q?cmdfR2CwcqgrDd3i33F8cEb8rdNhfx4yzE9b6QUADRB/kc3JgC3mWoFL/NPL?= =?us-ascii?Q?l5vo8LRmvWzXlpx2JG6Gd5xLi69M8trBhmTFuF3TYsdsyoGAjh3uNKUrT6Be?= =?us-ascii?Q?lqnC7arzntthSrf8IMuiZzwxHB9xuZHPcQE9BHc+2ZkEUgUpaRo59bWKrkmg?= =?us-ascii?Q?18DANOSdSY8dEuPhmesHHXxfJ8iYU7OY/7uBwVgAofNgYP/TNVLyCClozacj?= =?us-ascii?Q?qeasZbD7LCIEHv7OHbmFwDSVvt7C2/LN8l3rO64y2lv+l+Yaw6jaGCf98SD2?= =?us-ascii?Q?o8+vQN1KrMXBtl9hYriqOeTwf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-ascii?Q?qBf+uiDToRJ1j/yz8YB07GKOJ9Tah1ffkR48BcLNkFOjeS86p+Y4lntvKnh4?= =?us-ascii?Q?aSm575P8gMhNrUOJPEMBwsgbTgHM8bE28k98QeCHSm5NZ2dPNoJtd0lN2KPg?= =?us-ascii?Q?V15phqE52FNXrd7F0a9DWCY+GHGNAHVPew8GLxT+Agh3B14qMzsI1xoMqDp/?= =?us-ascii?Q?VdLSctVDkWXihkmZ/a6qi9SavwoLLl3JA7YvHwJ0Lm85wmqa4NdYzP81DHsT?= =?us-ascii?Q?73SUfFc9UCFsrPAsQDuAsuPhB5Z+7B+bVVCt3Ntgvck5LGqnzGCEqlo6NIsf?= =?us-ascii?Q?vsjrmnyjQiH0bd8Ta2ahYTBMxj/HNlw=3D?= Content-Type: text/plain; charset="us-ascii" Content-ID: Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: bb99f3a6-98d8-4012-e715-08da1165225e X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Mar 2022 09:18:49.1266 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: reGq0o4DnyfV+BHB90pKqrtIoSHuvHqtp2DQAHdJ6zEQZO3joMI7hfqdYh/K/pLdWxahkSg3xaVUNXEomZOBlA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR04MB8249 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 29, 2022 at 09:08:00AM +0000, Zheng Yongjun wrote: > As the possible failure of the allocation, kzalloc() may return NULL > pointer. > Therefore, it should be better to check the 'sgi' in order to prevent > the dereference of NULL pointer. >=20 > Fixes: 23ae3a7877718 ("net: dsa: felix: add stream gate settings for psfp= "). > Signed-off-by: Zheng Yongjun > --- Reviewed-by: Vladimir Oltean >=20 > v1->v2:Rewrite fixes tag, delete extra 'q'. >=20 > drivers/net/dsa/ocelot/felix_vsc9959.c | 4 ++++ > 1 file changed, 4 insertions(+) >=20 > diff --git a/drivers/net/dsa/ocelot/felix_vsc9959.c b/drivers/net/dsa/oce= lot/felix_vsc9959.c > index 33f0ceae381d..2875b5250856 100644 > --- a/drivers/net/dsa/ocelot/felix_vsc9959.c > +++ b/drivers/net/dsa/ocelot/felix_vsc9959.c > @@ -1940,6 +1940,10 @@ static int vsc9959_psfp_filter_add(struct ocelot *= ocelot, int port, > case FLOW_ACTION_GATE: > size =3D struct_size(sgi, entries, a->gate.num_entries); > sgi =3D kzalloc(size, GFP_KERNEL); > + if (!sgi) { > + ret =3D -ENOMEM; > + goto err; > + } > vsc9959_psfp_parse_gate(a, sgi); > ret =3D vsc9959_psfp_sgi_table_add(ocelot, sgi); > if (ret) { > --=20 > 2.17.1 >=