netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i40e: Fix possible memory leak in i40e_dbg_dump_desc
       [not found] <20141206134513.GD4963@mwanda>
@ 2014-12-06 14:03 ` Joe Perches
  2014-12-07 19:57   ` Jeff Kirsher
  0 siblings, 1 reply; 2+ messages in thread
From: Joe Perches @ 2014-12-06 14:03 UTC (permalink / raw)
  To: Jeff Kirsher
  Cc: kbuild, Shannon Nelson, Dan Carpenter, netdev, nhorman, sassmann,
	jogreene

I didn't notice that return in the code, fix it by
adding a goto out instead to free the memory.

Fixes:

> New smatch warnings:
> drivers/net/ethernet/intel/i40e/i40e_debugfs.c:832 i40e_dbg_dump_desc() warn: possible memory leak of 'ring'

Signed-off-by: Joe Perches <joe@perches.com>
Noticed-by: Dan Carpenter <dan.carpenter@oracle.com> (go smatch)
---

Jeff Kirsher can legitimately give me a hard time now...
Thanks Dan.

 drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
index 433a558..cb0de45 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_debugfs.c
@@ -829,7 +829,7 @@ static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
 		if (desc_n >= ring->count || desc_n < 0) {
 			dev_info(&pf->pdev->dev,
 				 "descriptor %d not found\n", desc_n);
-			return;
+			goto out;
 		}
 		if (!is_rx_ring) {
 			txd = I40E_TX_DESC(ring, desc_n);
@@ -855,6 +855,8 @@ static void i40e_dbg_dump_desc(int cnt, int vsi_seid, int ring_id, int desc_n,
 	} else {
 		dev_info(&pf->pdev->dev, "dump desc rx/tx <vsi_seid> <ring_id> [<desc_n>]\n");
 	}
+
+out:
 	kfree(ring);
 }
 

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] i40e: Fix possible memory leak in i40e_dbg_dump_desc
  2014-12-06 14:03 ` [PATCH] i40e: Fix possible memory leak in i40e_dbg_dump_desc Joe Perches
@ 2014-12-07 19:57   ` Jeff Kirsher
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Kirsher @ 2014-12-07 19:57 UTC (permalink / raw)
  To: Joe Perches
  Cc: kbuild, Shannon Nelson, Dan Carpenter, netdev, nhorman, sassmann,
	jogreene

[-- Attachment #1: Type: text/plain, Size: 692 bytes --]

On Sat, 2014-12-06 at 06:03 -0800, Joe Perches wrote:
> I didn't notice that return in the code, fix it by
> adding a goto out instead to free the memory.
> 
> Fixes:
> 
> > New smatch warnings:
> > drivers/net/ethernet/intel/i40e/i40e_debugfs.c:832
> i40e_dbg_dump_desc() warn: possible memory leak of 'ring'
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> Noticed-by: Dan Carpenter <dan.carpenter@oracle.com> (go smatch)
> ---
> 
> Jeff Kirsher can legitimately give me a hard time now...
> Thanks Dan.
> 
>  drivers/net/ethernet/intel/i40e/i40e_debugfs.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Thanks Joe, I have added your patch to my queue.

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-07 19:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20141206134513.GD4963@mwanda>
2014-12-06 14:03 ` [PATCH] i40e: Fix possible memory leak in i40e_dbg_dump_desc Joe Perches
2014-12-07 19:57   ` Jeff Kirsher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).