Commit f055e53e authored by Sakari Ailus's avatar Sakari Ailus Committed by Hans Verkuil

media: ccs: Correct error handling in ccs_register_subdev

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: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
parent 724ff68e
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment