summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSakari Ailus <sakari.ailus@linux.intel.com>2016-09-19 18:41:14 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-10-21 15:03:04 -0200
commit997695407512c3d0a7bf2f5e589ab288ac6d0f6b (patch)
treee5501a8a2c843564a33cdc78bafbf2328d496d8f /drivers
parent231d1a014aeb8c2288316572f2fe876c5145b91c (diff)
[media] smiapp: Fix resource management in registration failure
If the registered() callback failed, resources were left unaccounted for. Fix this, as well as add unregistering the sub-devices in driver unregistered() callback. Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Reviewed-by: Sebastian Reichel <sre@kernel.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/i2c/smiapp/smiapp-core.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/media/i2c/smiapp/smiapp-core.c b/drivers/media/i2c/smiapp/smiapp-core.c
index 8a58c641bc47..9d7af8b2ae8e 100644
--- a/drivers/media/i2c/smiapp/smiapp-core.c
+++ b/drivers/media/i2c/smiapp/smiapp-core.c
@@ -2524,12 +2524,22 @@ static int smiapp_register_subdev(struct smiapp_sensor *sensor,
if (rval) {
dev_err(&client->dev,
"media_create_pad_link failed\n");
+ v4l2_device_unregister_subdev(&ssd->sd);
return rval;
}
return 0;
}
+static void smiapp_unregistered(struct v4l2_subdev *subdev)
+{
+ struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
+ unsigned int i;
+
+ for (i = 1; i < sensor->ssds_used; i++)
+ v4l2_device_unregister_subdev(&sensor->ssds[i].sd);
+}
+
static int smiapp_registered(struct v4l2_subdev *subdev)
{
struct smiapp_sensor *sensor = to_smiapp_sensor(subdev);
@@ -2544,10 +2554,19 @@ static int smiapp_registered(struct v4l2_subdev *subdev)
return rval;
}
- return smiapp_register_subdev(
+ rval = smiapp_register_subdev(
sensor, sensor->pixel_array, sensor->binner,
SMIAPP_PA_PAD_SRC, SMIAPP_PAD_SINK,
MEDIA_LNK_FL_ENABLED | MEDIA_LNK_FL_IMMUTABLE);
+ if (rval)
+ goto out_err;
+
+ return 0;
+
+out_err:
+ smiapp_unregistered(subdev);
+
+ return rval;
}
static void smiapp_cleanup(struct smiapp_sensor *sensor)
@@ -2894,6 +2913,7 @@ static const struct media_entity_operations smiapp_entity_ops = {
static const struct v4l2_subdev_internal_ops smiapp_internal_src_ops = {
.registered = smiapp_registered,
+ .unregistered = smiapp_unregistered,
.open = smiapp_open,
.close = smiapp_close,
};