From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DD9C0C2BB48 for ; Mon, 14 Dec 2020 22:56:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DC05224F9 for ; Mon, 14 Dec 2020 22:56:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2439736AbgLNWzv (ORCPT ); Mon, 14 Dec 2020 17:55:51 -0500 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:46509 "EHLO relay7-d.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439348AbgLNWzY (ORCPT ); Mon, 14 Dec 2020 17:55:24 -0500 X-Originating-IP: 86.202.109.140 Received: from localhost (lfbn-lyo-1-13-140.w86-202.abo.wanadoo.fr [86.202.109.140]) (Authenticated sender: alexandre.belloni@bootlin.com) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id 6DC6620006; Mon, 14 Dec 2020 22:54:38 +0000 (UTC) Date: Mon, 14 Dec 2020 23:54:38 +0100 From: Alexandre Belloni To: Christophe JAILLET Cc: UNGLinuxDriver@microchip.com, vladimir.oltean@nxp.com, claudiu.manoil@nxp.com, davem@davemloft.net, kuba@kernel.org, andrew@lunn.ch, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [PATCH] net: mscc: ocelot: Fix a resource leak in the error handling path of the probe function Message-ID: <20201214225438.GY1781038@piout.net> References: <20201213114838.126922-1-christophe.jaillet@wanadoo.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201213114838.126922-1-christophe.jaillet@wanadoo.fr> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 13/12/2020 12:48:38+0100, Christophe JAILLET wrote: > In case of error after calling 'ocelot_init()', it must be undone by a > corresponding 'ocelot_deinit()' call, as already done in the remove > function. > > Fixes: a556c76adc05 ("net: mscc: Add initial Ocelot switch support") > Signed-off-by: Christophe JAILLET Acked-by: Alexandre Belloni > --- > drivers/net/ethernet/mscc/ocelot_vsc7514.c | 8 +++++++- > 1 file changed, 7 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/mscc/ocelot_vsc7514.c b/drivers/net/ethernet/mscc/ocelot_vsc7514.c > index 1e7729421a82..9cf2bc5f4289 100644 > --- a/drivers/net/ethernet/mscc/ocelot_vsc7514.c > +++ b/drivers/net/ethernet/mscc/ocelot_vsc7514.c > @@ -1267,7 +1267,7 @@ static int mscc_ocelot_probe(struct platform_device *pdev) > > err = mscc_ocelot_init_ports(pdev, ports); > if (err) > - goto out_put_ports; > + goto out_ocelot_deinit; > > if (ocelot->ptp) { > err = ocelot_init_timestamp(ocelot, &ocelot_ptp_clock_info); > @@ -1282,8 +1282,14 @@ static int mscc_ocelot_probe(struct platform_device *pdev) > register_switchdev_notifier(&ocelot_switchdev_nb); > register_switchdev_blocking_notifier(&ocelot_switchdev_blocking_nb); > > + of_node_put(ports); > + > dev_info(&pdev->dev, "Ocelot switch probed\n"); > > + return 0; > + > +out_ocelot_deinit: > + ocelot_deinit(ocelot); > out_put_ports: > of_node_put(ports); > return err; > -- > 2.27.0 > -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com