From nobody Sun Feb 8 02:22:03 2026 Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 128D114EFFF for ; Tue, 27 Feb 2024 20:51:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067077; cv=none; b=fZhXq/RzsWMBXhw8R4oDt1bbxfzP5oGPd1XMRZfiC1g1H5gNvZnHcUzAm6cVCYY36MWmuEs2cZ648XSf8DfcieIoyRYTR6qoMhEeGb0GFpPSJ2ALABTIlBa+muw23t7goBg5UCuXza3RSLJTTf2z8Nva0LSqZGecm+BULS38jvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067077; c=relaxed/simple; bh=8UZtwuLFt1gMui9a2Im7UgO6iF/un1cR2TCSHsPBa04=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Dd7CqpEbgo3f4ccu/XN3qYvCK4H6VrD7ApOFhh6qVRKMdWDuLpT7DOUDAQo1F6MiKVzVw4gIqQJZTCblUGyMU5xP8N0Bh92I0u8oVoF9QqCmCTgtP1oN17PkWK+ZDGKfgpHf3Afi14KPmDLo+5kJLgSboEoVWov2an1pMQomf1M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=gcWC20Sh; arc=none smtp.client-ip=80.12.242.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="gcWC20Sh" Received: from fedora.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id f4PjrRU7nxsbMf4PwrnVkS; Tue, 27 Feb 2024 21:51:12 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1709067072; bh=+f4AbVJbx28S60iHUgdJzBPh+asTj/MtBzhNY4Ac8Mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gcWC20ShNiGpb3YLDEDliWcB/JrBjMeZvLiuX67SiQq7eqjFdQUY2LHnAXwPqJNJY yWw2f7Uqpygzy9cv/62d5bB2+6RsO7P4lOL/IVjXvA6NI26jU5+9grghCbYdyp1OG4 jXp60QFwXgvk5vHlKq3j0r2bM5r+tY5/cuZ6Ng2EtGwPYYgA98JHMe927Qazz6XHXC opadKaVCYDe1tWN0/ZXKb2tMl+c6hRZCjdK9EKk17II29QnrlvJnmXESVkyMW2Gp5T 3cSWhIEHQZ33KHj7nh2o+UApC2K1iywSVoy+JVNjFJLD7wKtcMnhMSj6ozH0aGp086 MCm/cIjUeRNZw== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 27 Feb 2024 21:51:12 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: andy@greyhouse.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH net 1/2] net: tehuti: Fix a missing pci_disable_msi() in the error handling path of bdx_probe() Date: Tue, 27 Feb 2024 21:50:55 +0100 Message-ID: <011588ecfd6689e27237f96213acdb7a3543f981.1709066709.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If an error occurs after a successful call to pci_enable_msi(), pci_disable_msi() should be called as already done in the remove function. Add a new label and the missing pci_disable_msi() call. Fixes: 1a348ccc1047 ("[NET]: Add Tehuti network driver.") Signed-off-by: Christophe JAILLET --- Compile tested only. --- drivers/net/ethernet/tehuti/tehuti.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/te= huti/tehuti.c index ca409515ead5..938a5caf5a3b 100644 --- a/drivers/net/ethernet/tehuti/tehuti.c +++ b/drivers/net/ethernet/tehuti/tehuti.c @@ -1965,7 +1965,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_devi= ce_id *ent) ndev =3D alloc_etherdev(sizeof(struct bdx_priv)); if (!ndev) { err =3D -ENOMEM; - goto err_out_iomap; + goto err_out_disable_msi; } =20 ndev->netdev_ops =3D &bdx_netdev_ops; @@ -2031,7 +2031,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_devi= ce_id *ent) if (bdx_read_mac(priv)) { pr_err("load MAC address failed\n"); err =3D -EFAULT; - goto err_out_iomap; + goto err_out_disable_msi; } SET_NETDEV_DEV(ndev, &pdev->dev); err =3D register_netdev(ndev); @@ -2048,6 +2048,11 @@ bdx_probe(struct pci_dev *pdev, const struct pci_dev= ice_id *ent) =20 err_out_free: free_netdev(ndev); +err_out_disable_msi: +#ifdef BDX_MSI + if (nic->irq_type =3D=3D IRQ_MSI) + pci_disable_msi(pdev); +#endif err_out_iomap: iounmap(nic->regs); err_out_res: --=20 2.43.2 From nobody Sun Feb 8 02:22:03 2026 Received: from smtp.smtpout.orange.fr (smtp-27.smtpout.orange.fr [80.12.242.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 014A714F97C for ; Tue, 27 Feb 2024 20:51:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.12.242.27 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067077; cv=none; b=RHmnvD8w7SKJjPGdYhrYgzLkAwDA7g2udxZY2Ar4CNtQ25TUKq2XYVg10Vhh4EHW5d34BCmNb1Df0IJGfGQpOfuSrfml7mj/7pn0PpPrGp64pDtXy09RGX3mhPqoRmC9a2ReLvvaOruBeBVcbfaIBi+tDuMKwMh/2SShPISnlrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709067077; c=relaxed/simple; bh=C0EhGGIcvZ5dia6z/DMgXS0/s8mPCNUY3CZZl/PV8yI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QDTMAI9xLMlkFZtI1lNu4FxDeDLTDqjJsznvRw+dooD6dfpL4Cf8/4NsD5lQW03SpJ0YODAEY+u3tzg0lG6k2bHjIDGQhnuNLehrcs//beNXTwX4q6UpVuhDQidMGON0e9kTgY6uYG8BfDRdfoi8nAMt00deVYlzJOjhWLVd9Cg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr; spf=pass smtp.mailfrom=wanadoo.fr; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b=o63+GAqK; arc=none smtp.client-ip=80.12.242.27 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=wanadoo.fr Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=wanadoo.fr header.i=@wanadoo.fr header.b="o63+GAqK" Received: from fedora.home ([92.140.202.140]) by smtp.orange.fr with ESMTPA id f4PjrRU7nxsbMf4PxrnVkm; Tue, 27 Feb 2024 21:51:14 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1709067074; bh=7fh9n2YY+v7xWTDGOZYJY6/nuH13jrBRMC/bW8tKScA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=o63+GAqKGfx/mlADiFhta1gyxBFJ8uc639Wp16WrZKT6slPdnUDf17LNyr9/4eh// sDAicxQKAatVayHw1tHwmP6X4Y8F7GXuzcPSj2qBAFCuzAARKkhnWPYUZiPr7TSv8/ 4vbVBkC29wH8xASlmKeSWdw5FXA5LlBNvayZ+gBHD5aAUfCODUU5BnnGjWnsAQ/ZRO ap6xlASO0me8gaNIKO3O/ZITYI5HMMeQui98osjS3WjiFvEHlHgcN+6EFlFvCuO4L0 09Ggdh6XcrocUN3r4stlWPKqLRrVcrh/FYfT/mw5+ZYMnsf6FGgpMxC0QMGLnmsxxs bDRdjBlEij6Cw== X-ME-Helo: fedora.home X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 27 Feb 2024 21:51:14 +0100 X-ME-IP: 92.140.202.140 From: Christophe JAILLET To: andy@greyhouse.net, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET Subject: [PATCH net 2/2] net: tehuti: Fix leaks in the error handling path of bdx_probe() Date: Tue, 27 Feb 2024 21:50:56 +0100 Message-ID: <9090b599c7574892b77a9521e3ddb3a52a154205.1709066709.git.christophe.jaillet@wanadoo.fr> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" If an error occurs when allocating the net_device, all the one already allocated and registered should be released, as already done in the remove function. Add a new label, remove the now useless 'err_out_disable_msi' label and adjust the error handling path accordingly. Fixes: 1a348ccc1047 ("[NET]: Add Tehuti network driver.") Signed-off-by: Christophe JAILLET Reviewed-by: Jiri Pirko --- Compile tested only. --- drivers/net/ethernet/tehuti/tehuti.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/te= huti/tehuti.c index 938a5caf5a3b..6678179885cb 100644 --- a/drivers/net/ethernet/tehuti/tehuti.c +++ b/drivers/net/ethernet/tehuti/tehuti.c @@ -1965,7 +1965,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_devi= ce_id *ent) ndev =3D alloc_etherdev(sizeof(struct bdx_priv)); if (!ndev) { err =3D -ENOMEM; - goto err_out_disable_msi; + goto err_out_free; } =20 ndev->netdev_ops =3D &bdx_netdev_ops; @@ -2031,13 +2031,13 @@ bdx_probe(struct pci_dev *pdev, const struct pci_de= vice_id *ent) if (bdx_read_mac(priv)) { pr_err("load MAC address failed\n"); err =3D -EFAULT; - goto err_out_disable_msi; + goto err_out_free_current; } SET_NETDEV_DEV(ndev, &pdev->dev); err =3D register_netdev(ndev); if (err) { pr_err("register_netdev failed\n"); - goto err_out_free; + goto err_out_free_current; } netif_carrier_off(ndev); netif_stop_queue(ndev); @@ -2046,9 +2046,14 @@ bdx_probe(struct pci_dev *pdev, const struct pci_dev= ice_id *ent) } RET(0); =20 -err_out_free: +err_out_free_current: free_netdev(ndev); -err_out_disable_msi: +err_out_free: + while (--port >=3D 0) { + ndev =3D nic->priv[port]->ndev; + unregister_netdev(ndev); + free_netdev(ndev); + } #ifdef BDX_MSI if (nic->irq_type =3D=3D IRQ_MSI) pci_disable_msi(pdev); --=20 2.43.2