All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Cc: linux-media@vger.kernel.org
Subject: [PATCH v2 1/9] ov772x: Fix memory leak in probe error path
Date: Wed, 18 Jul 2012 15:58:18 +0200	[thread overview]
Message-ID: <1342619906-5820-2-git-send-email-laurent.pinchart@ideasonboard.com> (raw)
In-Reply-To: <1342619906-5820-1-git-send-email-laurent.pinchart@ideasonboard.com>

The control handler isn't freed if its initialization fails. Fix it.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 drivers/media/video/ov772x.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/video/ov772x.c b/drivers/media/video/ov772x.c
index 641f6f4..0fede50d 100644
--- a/drivers/media/video/ov772x.c
+++ b/drivers/media/video/ov772x.c
@@ -1098,18 +1098,17 @@ static int ov772x_probe(struct i2c_client *client,
 			V4L2_CID_BAND_STOP_FILTER, 0, 256, 1, 0);
 	priv->subdev.ctrl_handler = &priv->hdl;
 	if (priv->hdl.error) {
-		int err = priv->hdl.error;
-
-		kfree(priv);
-		return err;
+		ret = priv->hdl.error;
+		goto done;
 	}
 
 	ret = ov772x_video_probe(client);
+
+done:
 	if (ret) {
 		v4l2_ctrl_handler_free(&priv->hdl);
 		kfree(priv);
 	}
-
 	return ret;
 }
 
-- 
1.7.8.6


  reply	other threads:[~2012-07-18 13:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-18 13:58 [PATCH v2 0/9] Miscellaneous ov772x cleanups and fixes Laurent Pinchart
2012-07-18 13:58 ` Laurent Pinchart [this message]
2012-07-18 13:58 ` [PATCH v2 2/9] ov772x: Select the default format at probe time Laurent Pinchart
2012-07-18 13:58 ` [PATCH v2 3/9] ov772x: Don't fail in s_fmt if the requested format isn't supported Laurent Pinchart
2012-07-18 13:58 ` [PATCH v2 4/9] ov772x: try_fmt must not default to the current format Laurent Pinchart
2012-07-18 13:58 ` [PATCH v2 5/9] ov772x: Make to_ov772x convert from v4l2_subdev to ov772x_priv Laurent Pinchart
2012-07-18 13:58 ` [PATCH v2 6/9] ov772x: Add ov772x_read() and ov772x_write() functions Laurent Pinchart
2012-07-18 13:58 ` [PATCH v2 7/9] ov772x: Add support for SBGGR10 format Laurent Pinchart
2012-07-18 13:58 ` [PATCH v2 8/9] ov772x: Compute window size registers at runtime Laurent Pinchart
2012-07-20 13:58   ` Guennadi Liakhovetski
2012-07-20 14:14     ` Laurent Pinchart
2012-07-18 13:58 ` [PATCH v2 9/9] ov772x: Stop sensor readout right after reset Laurent Pinchart

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=1342619906-5820-2-git-send-email-laurent.pinchart@ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=g.liakhovetski@gmx.de \
    --cc=linux-media@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.