Patchwork openvswitch: small potential memory leak in ovs_vport_alloc()

login
register
mail settings
Submitter Dan Carpenter
Date Dec. 6, 2011, 6:27 a.m.
Message ID <20111206062707.GA8433@elgon.mountain>
Download mbox | patch
Permalink /patch/129569/
State Accepted
Delegated to: David Miller
Headers show

Comments

Dan Carpenter - Dec. 6, 2011, 6:27 a.m.
We're unlikely to hit this leak, but the static checkers complain if we
don't take care of it.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jesse Gross - Dec. 6, 2011, 5:32 p.m.
On Mon, Dec 5, 2011 at 10:27 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We're unlikely to hit this leak, but the static checkers complain if we
> don't take care of it.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Acked-by: Jesse Gross <jesse@nicira.com>

Thanks Dan.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Miller - Dec. 6, 2011, 5:59 p.m.
From: Jesse Gross <jesse@nicira.com>
Date: Tue, 6 Dec 2011 09:32:13 -0800

> On Mon, Dec 5, 2011 at 10:27 PM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
>> We're unlikely to hit this leak, but the static checkers complain if we
>> don't take care of it.
>>
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> Acked-by: Jesse Gross <jesse@nicira.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c
index 6cd7601..7f0ef37 100644
--- a/net/openvswitch/vport.c
+++ b/net/openvswitch/vport.c
@@ -127,8 +127,10 @@  struct vport *ovs_vport_alloc(int priv_size, const struct vport_ops *ops,
 	vport->ops = ops;
 
 	vport->percpu_stats = alloc_percpu(struct vport_percpu_stats);
-	if (!vport->percpu_stats)
+	if (!vport->percpu_stats) {
+		kfree(vport);
 		return ERR_PTR(-ENOMEM);
+	}
 
 	spin_lock_init(&vport->stats_lock);