Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3458369ybi; Fri, 5 Jul 2019 07:41:48 -0700 (PDT) X-Google-Smtp-Source: APXvYqxyckV6RPsUKEJ2dvQhFNdbdb7//306mbMsMTqd/DnxEAhjfVGJ2Pdl5g3/pEir517p2ArZ X-Received: by 2002:a63:fe15:: with SMTP id p21mr1466046pgh.149.1562337708738; Fri, 05 Jul 2019 07:41:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562337708; cv=none; d=google.com; s=arc-20160816; b=OkFjL9yVn+Tr2jJg4LNkbjHq5762XFsltvN1/xzVcyRu5fNz86g3fZbdK+cSe0JTMd Jvp5FEu623+I41s2NBwweJbTyJxHKZY9fZjgPTX7qiP7/kco5sqfjHN9n2n8S0igjnw3 skhiDhrwGnGWPmsZnSbEVZCdGlLELGZqmbs99fDgkvhQr10BCcI7f1eyoDqHNo4QfB6Z jGdiEZhCPb+6r/i100iEgxUKhGTiAwKzPqi4KvKYhqzQbSO1I6TiJSQHFBONp+oshwEp KFJjaUBLVWDT0gfM03G2+iK+6w8XWmRsRsRLZ6uoqV8cNtbULeJhGW7lEiSaY1WxAM2j wftw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:reply-to:references:in-reply-to :message-id:date:subject:cc:to:from; bh=Nw5hLIcUhbVbew+A9YpyMch0Tfi0x0PX98Jh4CCpqYQ=; b=ymxJ6pZ46vNyN2zN6eMMZBPYvhj//izH10dXxbfX0PV9OzfVEGk0f3TBgxCeZez4C0 RF8i3uo0mRsmGMasVxroVV7VtWQ8adF0S8SZBLjc2nP8A75Oy+oixZTI4w/x97UHCIb5 dT9roxi14thmqIM6aCb8NYvi2zZ0Rl9miJyWti3+59+cCsmBHzcsNiW5Q7lKrI5R+ZsM mJVm0VCsHzQEeT02yQ7X4GWEDwg7uNaMMTX5YCv6D87oobGbuMv1LCitIXOobgr5U4nZ CDUbBAn8cNtc16rtLz+Is2dMHxT9mp6QjcKxoh702yp8vBwCkijEVLuY5BztOCoQ874Z 40Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x10si10197499pfj.93.2019.07.05.07.41.33; Fri, 05 Jul 2019 07:41:48 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727649AbfGEO1i (ORCPT + 99 others); Fri, 5 Jul 2019 10:27:38 -0400 Received: from inva021.nxp.com ([92.121.34.21]:50614 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725813AbfGEO1U (ORCPT ); Fri, 5 Jul 2019 10:27:20 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id CB791200762; Fri, 5 Jul 2019 16:27:18 +0200 (CEST) Received: from inva024.eu-rdc02.nxp.com (inva024.eu-rdc02.nxp.com [134.27.226.22]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id BEA5E20076A; Fri, 5 Jul 2019 16:27:18 +0200 (CEST) Received: from fsr-ub1464-137.ea.freescale.net (fsr-ub1464-137.ea.freescale.net [10.171.82.114]) by inva024.eu-rdc02.nxp.com (Postfix) with ESMTP id 455B2204D6; Fri, 5 Jul 2019 16:27:18 +0200 (CEST) From: Ioana Ciornei To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: ruxandra.radulescu@nxp.com, Razvan Stefanescu , Ioana Ciornei Subject: [PATCH v2 3/6] staging: fsl-dpaa2/ethsw: Remove netdevice on port probing error Date: Fri, 5 Jul 2019 17:27:13 +0300 Message-Id: <1562336836-17119-4-git-send-email-ioana.ciornei@nxp.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1562336836-17119-1-git-send-email-ioana.ciornei@nxp.com> References: <1562336836-17119-1-git-send-email-ioana.ciornei@nxp.com> Reply-to: ioana.ciornei@nxp.com X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Razvan Stefanescu If the ethsw_port_init() call failed, the netdevice remains registered in the system. Use labels to ensure that netdevice is unregistered and freed in this case. Signed-off-by: Razvan Stefanescu Signed-off-by: Ioana Ciornei --- Changes in v2: - none drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c index b2273f840813..9f1617164865 100644 --- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c +++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c @@ -1460,13 +1460,23 @@ static int ethsw_probe_port(struct ethsw_core *ethsw, u16 port_idx) err = register_netdev(port_netdev); if (err < 0) { dev_err(dev, "register_netdev error %d\n", err); - free_netdev(port_netdev); - return err; + goto err_register_netdev; } ethsw->ports[port_idx] = port_priv; - return ethsw_port_init(port_priv, port_idx); + err = ethsw_port_init(port_priv, port_idx); + if (err) + goto err_ethsw_port_init; + + return 0; + +err_ethsw_port_init: + unregister_netdev(port_netdev); +err_register_netdev: + free_netdev(port_netdev); + + return err; } static int ethsw_probe(struct fsl_mc_device *sw_dev) -- 1.9.1