From patchwork Wed Sep 6 14:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13375687 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3144ED513 for ; Wed, 6 Sep 2023 14:16:36 +0000 (UTC) Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2073.outbound.protection.outlook.com [40.107.247.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1E3AE77; Wed, 6 Sep 2023 07:16:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q2WpI29mUTY9F8175s/Tp0POh2Z6hG6nHPahkBtTVNDnbcfN6Z183mEj6tf5cib6sEVTNtZnzqjJ/jqHZ+B5wv3Eyojrk1VF4Jv0vwClRHQeL7e9u9sL3E+HBKZt85hS9dzhVynDGYE5PaV+ACp99+EyGabx+zIYu/Wez399YTQ3wsmQU6n2D1P9UlVbql0TWUWY6YJrlCLy3JvQN2pIIiSUUXsGCItWzJ6HrJQqOR8me+5tA7XODuXUK18hxV4uZlJYveZGm+b9+RvY2cv5kkFgMKz3pL8u+cHQNDN9dHxTVPiIiwH42F8ayWDeM+k7NbFg1YuVg96Xknlgv2AOAg== 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=ND99i3z84ZiOeDEnaM57wSjeLHmjY5I44oirMiMw8SE=; b=Yi95FL7ssBNoAlkHeCHYwMcG++LDRj/8Djw9j3nZXZYvN0k0oKXtUcbIpS8elfDMd7huSedPg8Q1ob0LzO/8U0IsRTbQhaXdd68kfVgQq5YyeKYYN4n3VD9AAOUO8E0rigWkgQPCr7MfFs8HPzxNwKj9vBVGE1GArlHI2zeFHCwkGVaqhl6xJ1Wt5sNZscvkYfWstH/S7F8/m4kpdslGV1Q0dhuyIBYwEIQES/9O/N5GoSmLmSRhftC5cfMJqtf85MHvwHpQU99BnA0R2eX+V00fRg8k7ofuZ0u/zYLubp7V8HL/dwPK9vmsIJU3VTPicqWiPLh6TPsom67ZMghTwg== 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=ND99i3z84ZiOeDEnaM57wSjeLHmjY5I44oirMiMw8SE=; b=P2SYdfhZ2LhnFfkcHgo48xuzTI9Gvi3amtx1lQhUSMICCfV50GgzuR0eKtbjbRthzdqhFKCERYY1Jp976ITGsNecpPt8RNy5/2mfMk2yF1Z1F9rnz3ox0VHWcwGHkcXKrLy80+rhB6WWpAMDkjxAqn2mUEiFeE4F2McPSSHajTo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) by PAXPR04MB8375.eurprd04.prod.outlook.com (2603:10a6:102:1be::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6745.33; Wed, 6 Sep 2023 14:16:30 +0000 Received: from AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454]) by AM0PR04MB6452.eurprd04.prod.outlook.com ([fe80::568a:57ee:35b5:e454%3]) with mapi id 15.20.6745.030; Wed, 6 Sep 2023 14:16:30 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org, Claudiu Manoil Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-kernel@vger.kernel.org, Dan Carpenter Subject: [PATCH net] net: enetc: distinguish error from valid pointers in enetc_fixup_clear_rss_rfs() Date: Wed, 6 Sep 2023 17:16:09 +0300 Message-Id: <20230906141609.247579-1-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: AM0PR05CA0077.eurprd05.prod.outlook.com (2603:10a6:208:136::17) To AM0PR04MB6452.eurprd04.prod.outlook.com (2603:10a6:208:16d::21) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB6452:EE_|PAXPR04MB8375:EE_ X-MS-Office365-Filtering-Correlation-Id: 4450e2d1-c1ac-4915-1ace-08dbaee3dda8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6g9+VIsk5nmawL5lsN0EeqgphlpVhW/jldGxlJP13A7GboKCBQyKaWnichwjhjFoHpC/nFeWjokbsHRfhlEWaYCJOgVGcb48eDG+2wvHISjZnDEmuJG8ctMUM6XNcAMUrtSFc/5+uAwqF2nxux5o/bmneBjnJJ/IPB4cLdhibyqt96sftLlWvlOBXUGsFqi3683jaj1K9VbsA2O0KhGzcuYP4ZaKbS0a16pufsKJVhux564VdGLTVaBmaUJ7WD+Fw/mQqWw459lNVeqbqT30ek3t4/eFYC8Lv8vOvAxN+LID2nwEo5Cvj28w8QwW+VGA4pYMZE8h01lSalEWU3KXlGxsltd0A8c18F4EMRVjobEq2pOdS2K17NOBblK9d18pBvopgT+NbaJSwqlQCxa57puD7vXX73U9udLAReakUCOOFzQE939APZkGEfR16iMIjwPBj1KiPv+rCtG3fMNZP6828jG2fLcnL8zYDl1m1pxgvtO04+HQMpoTHGxnVD4XHJ574eQcfRCUFfLE8zGVg8dRmbUDVMksRBm8Covc0v0BTP9gadn1yhLE4GN3X8Pv03HwozuEGnBPxWbjPnbZSpB1ndVxPhYuB3MBWx9gQtE= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB6452.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(39860400002)(346002)(396003)(366004)(136003)(186009)(451199024)(1800799009)(41300700001)(38100700002)(86362001)(6666004)(2616005)(38350700002)(83380400001)(966005)(478600001)(1076003)(26005)(6512007)(6486002)(52116002)(6506007)(36756003)(66946007)(66476007)(6636002)(2906002)(37006003)(66556008)(54906003)(316002)(5660300002)(8936002)(6862004)(8676002)(4326008)(44832011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YFWcQkW3aXegdu6ExEhrIPwHrHnw050VryURKh+f4/JkG9As+WWsX2HwuR4bOhkkeD9Zk9bziFAtNGpNtMHOHaJQ3jmiaZFFOCPkp23wdcI7C0V9VvmrAU20mSqt91SLe8ZZro/98+e4eaPn0ghajrAF34+oGYJ2U16GOgZY2PPWow84/GWbjnegEWPgqUSRS7Gae0ON7N1TfVGSV4aczCMbSFMGGJyj20RD3xtG9m7IBS/tvyVrdSyumievh3yDVVBm3QN2xoVps1suZecTn+J4EHRWCKZtUWUqj4nay7t/2ZRpsxHM1q36SbMeovCWkIEsb4pZAkQPnh6mooHhzene0ZkrtHriltmJdZQPvKnpiHCYr69gQDW5bMxKoVNwxdhD5aD2EZ/LnDLMJwSV7YeQZVniJwnT/qH5axArjYwD+DpaR2YDLsl7M65pHHiIGlWyrYxIvnesZ0745mBARCwaJpBY/rdLIwMWseksSC+vCSqYtb8ylEI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kQCh/vAhU+tD4YK/v/N7W3uQ9ACH77E4j7ugvCGO0urnABVg== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4450e2d1-c1ac-4915-1ace-08dbaee3dda8 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB6452.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2023 14:16:30.4600 (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: DXrh8bd66LgxThVtbS50QrcQl+gIPoHKlDccFJH54iXnwiKO7p2EtLmiBXp7kmfaGJNwY8rGAa7LqdrLgxj+vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8375 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 autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org enetc_psi_create() returns an ERR_PTR() or a valid station interface pointer, but checking for the non-NULL quality of the return code blurs that difference away. So if enetc_psi_create() fails, we call enetc_psi_destroy() when we shouldn't. This will likely result in crashes, since enetc_psi_create() cleans up everything after itself when it returns an ERR_PTR(). Fixes: f0168042a212 ("net: enetc: reimplement RFS/RSS memory clearing as PCI quirk") Reported-by: Dan Carpenter Closes: https://lore.kernel.org/netdev/582183ef-e03b-402b-8e2d-6d9bb3c83bd9@moroto.mountain/ Suggested-by: Dan Carpenter Signed-off-by: Vladimir Oltean Reviewed-by: Simon Horman --- drivers/net/ethernet/freescale/enetc/enetc_pf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c index e0a4cb7e3f50..c153dc083aff 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c +++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c @@ -1402,7 +1402,7 @@ static void enetc_fixup_clear_rss_rfs(struct pci_dev *pdev) return; si = enetc_psi_create(pdev); - if (si) + if (!IS_ERR(si)) enetc_psi_destroy(pdev); } DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_FREESCALE, ENETC_DEV_ID_PF,