From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: linux-media@vger.kernel.org
Cc: laurent.pinchart@ideasonboard.com,
Tianshu Qiu <tian.shu.qiu@intel.com>,
Bingbu Cao <bingbu.cao@intel.com>,
Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
Jacopo Mondi <jacopo+renesas@jmondi.org>
Subject: [PATCH 4/7] media: ccs: Correct error handling in ccs_register_subdev
Date: Fri, 15 Sep 2023 10:28:06 +0300 [thread overview]
Message-ID: <20230915072809.37886-5-sakari.ailus@linux.intel.com> (raw)
In-Reply-To: <20230915072809.37886-1-sakari.ailus@linux.intel.com>
ccs_register_subdev() did not clean up the media entity in error case, do
that now. Also switch to goto based error handling.
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
---
drivers/media/i2c/ccs/ccs-core.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/media/i2c/ccs/ccs-core.c b/drivers/media/i2c/ccs/ccs-core.c
index 6f8fbd82e21c..3fed071b65ab 100644
--- a/drivers/media/i2c/ccs/ccs-core.c
+++ b/drivers/media/i2c/ccs/ccs-core.c
@@ -2968,7 +2968,7 @@ static int ccs_register_subdev(struct ccs_sensor *sensor,
rval = v4l2_device_register_subdev(sensor->src->sd.v4l2_dev, &ssd->sd);
if (rval) {
dev_err(&client->dev, "v4l2_device_register_subdev failed\n");
- return rval;
+ goto out_media_entity_cleanup;
}
rval = media_create_pad_link(&ssd->sd.entity, source_pad,
@@ -2976,11 +2976,18 @@ static int ccs_register_subdev(struct ccs_sensor *sensor,
link_flags);
if (rval) {
dev_err(&client->dev, "media_create_pad_link failed\n");
- v4l2_device_unregister_subdev(&ssd->sd);
- return rval;
+ goto out_v4l2_device_unregister_subdev;
}
return 0;
+
+out_v4l2_device_unregister_subdev:
+ v4l2_device_unregister_subdev(&ssd->sd);
+
+out_media_entity_cleanup:
+ media_entity_cleanup(&ssd->sd.entity);
+
+ return rval;
}
static void ccs_unregistered(struct v4l2_subdev *subdev)
--
2.39.2
next prev parent reply other threads:[~2023-09-15 7:28 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 7:28 [PATCH 0/7] Small fixes and cleanups (ov2740 and ccs) Sakari Ailus
2023-09-15 7:28 ` [PATCH 1/7] media: Documentation: Align numbered list, make it a proper ReST Sakari Ailus
2023-09-15 9:17 ` Laurent Pinchart
2023-09-15 7:28 ` [PATCH 2/7] media: ccs: Fix driver quirk struct documentation Sakari Ailus
2023-09-15 9:18 ` Laurent Pinchart
2023-09-15 7:28 ` [PATCH 3/7] media: ccs: Correctly initialise try compose rectangle Sakari Ailus
2023-09-15 9:19 ` Laurent Pinchart
2023-09-15 9:48 ` Sakari Ailus
2023-09-15 7:28 ` Sakari Ailus [this message]
2023-09-15 9:33 ` [PATCH 4/7] media: ccs: Correct error handling in ccs_register_subdev Laurent Pinchart
2023-09-15 7:28 ` [PATCH 5/7] media: ov2740: Enable runtime PM before registering the async subdev Sakari Ailus
2023-09-15 9:42 ` Laurent Pinchart
2023-09-15 10:09 ` Sakari Ailus
2023-09-15 11:30 ` Laurent Pinchart
2023-09-15 11:48 ` Sakari Ailus
2023-09-15 12:16 ` Laurent Pinchart
2023-09-15 15:50 ` Sakari Ailus
2023-09-15 16:11 ` Laurent Pinchart
2023-09-15 20:31 ` Sakari Ailus
2023-09-15 20:39 ` Laurent Pinchart
2023-09-15 7:28 ` [PATCH 6/7] media: ov2740: Use sub-device active state Sakari Ailus
2023-09-15 9:48 ` Laurent Pinchart
2023-09-15 9:54 ` Sakari Ailus
2023-09-15 10:13 ` Laurent Pinchart
2023-09-15 10:27 ` Sakari Ailus
2023-09-15 11:31 ` Laurent Pinchart
2023-09-15 11:53 ` Sakari Ailus
2023-09-15 12:08 ` Laurent Pinchart
2023-09-15 7:28 ` [PATCH 7/7] media: ov2740: Return -EPROBE_DEFER if no endpoint is found Sakari Ailus
2023-09-15 9:50 ` Laurent Pinchart
2023-09-15 20:25 ` Sakari Ailus
2023-09-29 12:37 ` Sakari Ailus
2023-09-29 14:25 ` Hans de Goede
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=20230915072809.37886-5-sakari.ailus@linux.intel.com \
--to=sakari.ailus@linux.intel.com \
--cc=bingbu.cao@intel.com \
--cc=jacopo+renesas@jmondi.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-media@vger.kernel.org \
--cc=tian.shu.qiu@intel.com \
--cc=tomi.valkeinen@ideasonboard.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox