All of lore.kernel.org
 help / color / mirror / Atom feed
From: Janusz Krzysztofik <jmkrzyszt@gmail.com>
To: Mauro Carvalho Chehab <mchehab@kernel.org>
Cc: Sakari Ailus <sakari.ailus@linux.intel.com>,
	Hans Verkuil <hans.verkuil@cisco.com>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, Janusz Krzysztofik <jmkrzyszt@gmail.com>
Subject: [PATCH 02/14] media: ov6650: Fix control handler not freed on init error
Date: Mon,  8 Apr 2019 23:42:30 +0200	[thread overview]
Message-ID: <20190408214242.9603-3-jmkrzyszt@gmail.com> (raw)
In-Reply-To: <20190408214242.9603-1-jmkrzyszt@gmail.com>

Since commit afd9690c72c3 ("[media] ov6650: convert to the control
framework"), if an error occurs during initialization of a control
handler, resources possibly allocated to the handler are not freed
before device initialiaton is aborted.  Fix it.

Fixes: afd9690c72c3 ("[media] ov6650: convert to the control framework")
Signed-off-by: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Cc: stable@vger.kernel.org
---
 drivers/media/i2c/ov6650.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/media/i2c/ov6650.c b/drivers/media/i2c/ov6650.c
index a3d00afcb0c8..007f0ca24913 100644
--- a/drivers/media/i2c/ov6650.c
+++ b/drivers/media/i2c/ov6650.c
@@ -992,8 +992,10 @@ static int ov6650_probe(struct i2c_client *client,
 			V4L2_CID_GAMMA, 0, 0xff, 1, 0x12);
 
 	priv->subdev.ctrl_handler = &priv->hdl;
-	if (priv->hdl.error)
-		return priv->hdl.error;
+	if (priv->hdl.error) {
+		ret = priv->hdl.error;
+		goto ectlhdlfree;
+	}
 
 	v4l2_ctrl_auto_cluster(2, &priv->autogain, 0, true);
 	v4l2_ctrl_auto_cluster(3, &priv->autowb, 0, true);
@@ -1012,8 +1014,10 @@ static int ov6650_probe(struct i2c_client *client,
 	priv->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
 
 	ret = v4l2_async_register_subdev(&priv->subdev);
-	if (ret)
-		v4l2_ctrl_handler_free(&priv->hdl);
+	if (!ret)
+		return 0;
+ectlhdlfree:
+	v4l2_ctrl_handler_free(&priv->hdl);
 
 	return ret;
 }
-- 
2.21.0


  parent reply	other threads:[~2019-04-08 21:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-08 21:42 [PATCH 00/14] media: ov6650: A collection of fixes Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 01/14] media: ov6650: Fix MODDULE_DESCRIPTION Janusz Krzysztofik
2019-04-08 21:42 ` Janusz Krzysztofik [this message]
2019-04-08 21:42 ` [PATCH 03/14] media: ov6650: Fix unverified arguments used in .set_fmt() Janusz Krzysztofik
2019-04-30 13:58   ` Sakari Ailus
2019-05-07 23:33     ` Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 04/14] media: ov6650: Fix unverified arguments accepted by .get_fmt() Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 05/14] media: ov6650: Fix unverified arguments accepted by .enum_mbus_code() Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 06/14] media: ov6650: Fix unverified pad IDs accepted by .get/set_selectioon() Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 07/14] media: ov6650: Fix unverified pad IDs accepted by .g/s_frame_interval() Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 08/14] media: ov6650: Fix crop rectangle alignment not passed back Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 09/14] media: ov6650: Fix incorrect use of JPEG colorspace Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 10/14] media: ov6650: Fix some format attributes not under control Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 11/14] media: ov6650: Fix .get_fmt() V4L2_SUBDEV_FORMAT_TRY support Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 12/14] media: ov6650: Fix default format not applied on device probe Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 13/14] media: ov6650: Fix stored frame format not in sync with hardware Janusz Krzysztofik
2019-04-08 21:42 ` [PATCH 14/14] media: ov6650: Fix stored crop rectangle " Janusz Krzysztofik

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=20190408214242.9603-3-jmkrzyszt@gmail.com \
    --to=jmkrzyszt@gmail.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=stable@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.