Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9109555pxu; Mon, 28 Dec 2020 06:53:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJx7E+quneM3FshL4EQs/R/CIaN+Z5nef9Zd6bJZ7QaZaBnizIy/9PQdQMfmNgrmbHRqjRHV X-Received: by 2002:a17:906:7b8d:: with SMTP id s13mr41546776ejo.479.1609167215902; Mon, 28 Dec 2020 06:53:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167215; cv=none; d=google.com; s=arc-20160816; b=wvDypKOmqB53xnlbFWBTg3NBubNX9zthHnODnqwA3vuoHTjZFv/g+dsPuCFutwnSe8 uXl2mDqtPT2wgRRw91RF3PbgHLg7rVHMvBgWEM92X0kRvEnBeSueA8IiQt6KBYBdaGlf 86SYc3WCSAB2Un55kdsW4uxKn+ccNf4QmsPJaW/8XsGyww+3bzLZJNnPfbeq2Ffeh5hB gAQ1b+OX55c+Bt0c+UnyZ9l7l1itoLAPQ5MNbwPJXG7a/7/p9LRZ0oiOUp/nSVoM6PVn fFwvKUsL1HooUZkVQjRU/3M0ChchjoDC2E7auspYdI7IKZBSDqQl3jbBKjSBFyki0ecx 22Tw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=BIN8p1cvv862Z2bMVF944Ys9emKFqfNU2B4Wo73849w=; b=RyEXm0s3aBUE4Q8AB1le1+hYIQAbV6UibJ2Pq8+L9y/2/Kk2FRVws4oElSwt92OKMN hZrtkP6suNty8jRh/4zuIsukypCbBOOo611caOUYWAUHadbkFQpAGWnDiK/aMhkFER6H lpb7PncR9Wmyup8ukyRsZ+/N+VegRYlrrzCJcAT3sZ4kdCFOHkTO3ZNE+oK/Xr9GOSHP MCW9apLQ9zqof2gG1Cub2x7AciSVAPlBIayjRttCsvu2HE0hZLK8BNW6AVfKraJ3Auf0 tm++df2+yFm2bM7GW0kWwYYMx5t4LJxMrFDvbURwwXUX6pDriY9DJ2yhit8ov0V6ov9y yj4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vaDMMUMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m19si20677674edb.315.2020.12.28.06.53.10; Mon, 28 Dec 2020 06:53:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vaDMMUMl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392179AbgL1Ot5 (ORCPT + 99 others); Mon, 28 Dec 2020 09:49:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:57204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437948AbgL1OVf (ORCPT ); Mon, 28 Dec 2020 09:21:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 90B7722CB9; Mon, 28 Dec 2020 14:20:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165255; bh=xDlOt0jpK9eElgV1QaTMzGTGvnCs2EIRpHJLnub4fic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vaDMMUMlVuPm6blIskmFvbjSPR4qvuYPt+hFmSY4rM5vVNoSmu+xipkx+1VBalU9N ky0VQVKReHZHC2DZOy5Wp9KnnZ20qzMvu5r90lOM39MX2OtCQXn1ia5FkLNITHgb9d ghcdAdKy5cQsuWdpr4lw6lwll2OImYQrTXwn5WOw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Alexandre Belloni , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 467/717] net: mscc: ocelot: Fix a resource leak in the error handling path of the probe function Date: Mon, 28 Dec 2020 13:47:45 +0100 Message-Id: <20201228125043.345137184@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET [ Upstream commit f87675b836b324d270fd52f1f5e6d6bb9f4bd1d5 ] 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 Link: https://lore.kernel.org/r/20201213114838.126922-1-christophe.jaillet@wanadoo.fr Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- 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 1e7729421a825..9cf2bc5f42892 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