public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public•gmane.org>
To: Jesse Gross <jesse-l0M0P4e3n4LQT0dZR+AlfA@public•gmane.org>
Cc: dev-yBygre7rU0TnMu66kgdUjQ@public•gmane.org,
	netdev-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public•gmane.org,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public•gmane.org>
Subject: [patch] openvswitch: small potential memory leak in ovs_vport_alloc()
Date: Tue, 6 Dec 2011 09:27:07 +0300	[thread overview]
Message-ID: <20111206062707.GA8433@elgon.mountain> (raw)

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-QHcLZuEGTsvQT0dZR+AlfA@public•gmane.org>

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);
 

             reply	other threads:[~2011-12-06  6:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-06  6:27 Dan Carpenter [this message]
     [not found] ` <20111206062707.GA8433-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2011-12-06 17:32   ` [patch] openvswitch: small potential memory leak in ovs_vport_alloc() Jesse Gross
     [not found]     ` <CAEP_g=_McLiPzKMM-9PGqddsYe7q6jYkCyAJcE1MU=Q4_Fou4g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-06 17:59       ` David Miller

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=20111206062707.GA8433@elgon.mountain \
    --to=dan.carpenter-qhclzuegtsvqt0dzr+alfa@public$(echo .)gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public$(echo .)gmane.org \
    --cc=dev-yBygre7rU0TnMu66kgdUjQ@public$(echo .)gmane.org \
    --cc=jesse-l0M0P4e3n4LQT0dZR+AlfA@public$(echo .)gmane.org \
    --cc=kernel-janitors-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    --cc=netdev-u79uwXL29TY76Z2rM5mHXA@public$(echo .)gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox