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