All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Christophe JAILLET <christophe.jaillet@wanadoo.fr>,
	"David S . Miller" <davem@davemloft.net>,
	Sasha Levin <sashal@kernel.org>,
	netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.4 04/14] net/sonic: Fix a resource leak in an error handling path in 'jazz_sonic_probe()'
Date: Thu, 14 May 2020 14:56:15 -0400	[thread overview]
Message-ID: <20200514185625.21753-4-sashal@kernel.org> (raw)
In-Reply-To: <20200514185625.21753-1-sashal@kernel.org>

From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

[ Upstream commit 10e3cc180e64385edc9890c6855acf5ed9ca1339 ]

A call to 'dma_alloc_coherent()' is hidden in 'sonic_alloc_descriptors()',
called from 'sonic_probe1()'.

This is correctly freed in the remove function, but not in the error
handling path of the probe function.
Fix it and add the missing 'dma_free_coherent()' call.

While at it, rename a label in order to be slightly more informative.

Fixes: efcce839360f ("[PATCH] macsonic/jazzsonic network drivers update")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/net/ethernet/natsemi/jazzsonic.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/natsemi/jazzsonic.c b/drivers/net/ethernet/natsemi/jazzsonic.c
index acf3f11e38cc1..68d2f31921ff8 100644
--- a/drivers/net/ethernet/natsemi/jazzsonic.c
+++ b/drivers/net/ethernet/natsemi/jazzsonic.c
@@ -247,13 +247,15 @@ static int jazz_sonic_probe(struct platform_device *pdev)
 		goto out;
 	err = register_netdev(dev);
 	if (err)
-		goto out1;
+		goto undo_probe1;
 
 	printk("%s: MAC %pM IRQ %d\n", dev->name, dev->dev_addr, dev->irq);
 
 	return 0;
 
-out1:
+undo_probe1:
+	dma_free_coherent(lp->device, SIZEOF_SONIC_DESC * SONIC_BUS_SCALE(lp->dma_bitmode),
+			  lp->descriptors, lp->descriptors_laddr);
 	release_mem_region(dev->base_addr, SONIC_MEM_SIZE);
 out:
 	free_netdev(dev);
-- 
2.20.1


  parent reply	other threads:[~2020-05-14 18:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-14 18:56 [PATCH AUTOSEL 4.4 01/14] Makefile: disallow data races on gcc-10 as well Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 02/14] HID: multitouch: add eGalaxTouch P80H84 support Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 03/14] batman-adv: fix batadv_nc_random_weight_tq Sasha Levin
2020-05-14 18:56 ` Sasha Levin [this message]
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 05/14] dp83640: reverse arguments to list_add_tail Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 06/14] soc: qcom: ipa: IPA endpoints Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 07/14] net: ipa: fix a bug in ipa_endpoint_stop() Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 08/14] net: moxa: Fix a potential double 'free_irq()' Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 09/14] ceph: fix double unlock in handle_cap_export() Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 10/14] net/mlx4_core: Fix use of ENOSPC around mlx4_counter_alloc() Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 11/14] USB: core: Fix misleading driver bug report Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 12/14] platform/x86: asus-nb-wmi: Do not load on Asus T100TA and T200TA Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 13/14] ARM: futex: Address build warning Sasha Levin
2020-05-14 18:56   ` Sasha Levin
2020-05-14 18:56 ` [PATCH AUTOSEL 4.4 14/14] scripts/decodecode: fix trapping instruction formatting Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200514185625.21753-4-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=christophe.jaillet@wanadoo.fr \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.