* [PATCH] net: mvpp2: fix possible memory leak
@ 2014-11-01 11:29 Sudip Mukherjee
2014-11-01 19:12 ` David Miller
2014-11-01 22:24 ` Thomas Petazzoni
0 siblings, 2 replies; 4+ messages in thread
From: Sudip Mukherjee @ 2014-11-01 11:29 UTC (permalink / raw)
To: David S. Miller; +Cc: Sudip Mukherjee, netdev, linux-kernel
we are allocating memory using kzalloc for struct mvpp2_prs_entry,
but later when we are getting error we were just returning the error
value without releasing the memory.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
hi,
i could not build test after modifying it. I tried to compile using
multi_v7_defconfig , but the cross compiler i have is not able to
compile it and giving sevaral warnings from the assembler.
drivers/net/ethernet/marvell/mvpp2.c | 27 ++++++++++++++++++---------
1 file changed, 18 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c
index ece83f1..c4382b3 100644
--- a/drivers/net/ethernet/marvell/mvpp2.c
+++ b/drivers/net/ethernet/marvell/mvpp2.c
@@ -1692,6 +1692,7 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
{
struct mvpp2_prs_entry *pe;
int tid_aux, tid;
+ int ret = 0;
pe = mvpp2_prs_vlan_find(priv, tpid, ai);
@@ -1723,8 +1724,10 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
break;
}
- if (tid <= tid_aux)
- return -EINVAL;
+ if (tid <= tid_aux) {
+ ret = -EINVAL;
+ goto error;
+ }
memset(pe, 0 , sizeof(struct mvpp2_prs_entry));
mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN);
@@ -1756,9 +1759,10 @@ static int mvpp2_prs_vlan_add(struct mvpp2 *priv, unsigned short tpid, int ai,
mvpp2_prs_hw_write(priv, pe);
+error:
kfree(pe);
- return 0;
+ return ret;
}
/* Get first free double vlan ai number */
@@ -1821,7 +1825,7 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
unsigned int port_map)
{
struct mvpp2_prs_entry *pe;
- int tid_aux, tid, ai;
+ int tid_aux, tid, ai, ret = 0;
pe = mvpp2_prs_double_vlan_find(priv, tpid1, tpid2);
@@ -1838,8 +1842,10 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
/* Set ai value for new double vlan entry */
ai = mvpp2_prs_double_vlan_ai_free_get(priv);
- if (ai < 0)
- return ai;
+ if (ai < 0) {
+ ret = ai;
+ goto error;
+ }
/* Get first single/triple vlan tid */
for (tid_aux = MVPP2_PE_FIRST_FREE_TID;
@@ -1859,8 +1865,10 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
break;
}
- if (tid >= tid_aux)
- return -ERANGE;
+ if (tid >= tid_aux) {
+ ret = -ERANGE;
+ goto error;
+ }
memset(pe, 0, sizeof(struct mvpp2_prs_entry));
mvpp2_prs_tcam_lu_set(pe, MVPP2_PRS_LU_VLAN);
@@ -1887,8 +1895,9 @@ static int mvpp2_prs_double_vlan_add(struct mvpp2 *priv, unsigned short tpid1,
mvpp2_prs_tcam_port_map_set(pe, port_map);
mvpp2_prs_hw_write(priv, pe);
+error:
kfree(pe);
- return 0;
+ return ret;
}
/* IPv4 header parsing for fragmentation and L4 offset */
--
1.8.1.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mvpp2: fix possible memory leak
2014-11-01 11:29 [PATCH] net: mvpp2: fix possible memory leak Sudip Mukherjee
@ 2014-11-01 19:12 ` David Miller
2014-11-01 22:24 ` Thomas Petazzoni
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-11-01 19:12 UTC (permalink / raw)
To: sudipm.mukherjee; +Cc: netdev, linux-kernel
From: Sudip Mukherjee <sudipm.mukherjee@gmail.com>
Date: Sat, 1 Nov 2014 16:59:34 +0530
> we are allocating memory using kzalloc for struct mvpp2_prs_entry,
> but later when we are getting error we were just returning the error
> value without releasing the memory.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
Applied, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mvpp2: fix possible memory leak
2014-11-01 11:29 [PATCH] net: mvpp2: fix possible memory leak Sudip Mukherjee
2014-11-01 19:12 ` David Miller
@ 2014-11-01 22:24 ` Thomas Petazzoni
2014-11-02 6:19 ` Sudip Mukherjee
1 sibling, 1 reply; 4+ messages in thread
From: Thomas Petazzoni @ 2014-11-01 22:24 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: David S. Miller, netdev, linux-kernel
Dear Sudip Mukherjee,
On Sat, 1 Nov 2014 16:59:34 +0530, Sudip Mukherjee wrote:
> we are allocating memory using kzalloc for struct mvpp2_prs_entry,
> but later when we are getting error we were just returning the error
> value without releasing the memory.
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> hi,
> i could not build test after modifying it. I tried to compile using
> multi_v7_defconfig , but the cross compiler i have is not able to
> compile it and giving sevaral warnings from the assembler.
That seems weird. Which compiler are you using, and which errors were
you getting?
In any case, it would have been good to Cc the authors of the driver.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: mvpp2: fix possible memory leak
2014-11-01 22:24 ` Thomas Petazzoni
@ 2014-11-02 6:19 ` Sudip Mukherjee
0 siblings, 0 replies; 4+ messages in thread
From: Sudip Mukherjee @ 2014-11-02 6:19 UTC (permalink / raw)
To: Thomas Petazzoni; +Cc: David S. Miller, netdev, linux-kernel, Marcin Wojtas
On Sat, Nov 01, 2014 at 11:24:45PM +0100, Thomas Petazzoni wrote:
> Dear Sudip Mukherjee,
>
> On Sat, 1 Nov 2014 16:59:34 +0530, Sudip Mukherjee wrote:
> > we are allocating memory using kzalloc for struct mvpp2_prs_entry,
> > but later when we are getting error we were just returning the error
> > value without releasing the memory.
> >
> > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> > ---
> >
> > hi,
> > i could not build test after modifying it. I tried to compile using
> > multi_v7_defconfig , but the cross compiler i have is not able to
> > compile it and giving sevaral warnings from the assembler.
>
> That seems weird. Which compiler are you using, and which errors were
> you getting?
>
> In any case, it would have been good to Cc the authors of the driver.
yes, i should have. Ccing now. better late than never.
i am using gcc version 4.3.2 (Sourcery G++ Lite 2008q3-72).
thanks
sudip
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux, Kernel and Android engineering
> http://free-electrons.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-11-02 6:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-01 11:29 [PATCH] net: mvpp2: fix possible memory leak Sudip Mukherjee
2014-11-01 19:12 ` David Miller
2014-11-01 22:24 ` Thomas Petazzoni
2014-11-02 6:19 ` Sudip Mukherjee
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox