Commit ba7a93e5 authored by Dan Carpenter's avatar Dan Carpenter Committed by Mauro Carvalho Chehab
Browse files

media: v4l2-subdev: fix some NULL vs IS_ERR() checks



The v4l2_subdev_alloc_state() function returns error pointers, it
doesn't return NULL.

Fixes: 0d346d2a ("media: v4l2-subdev: add subdev-wide state struct")
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarHans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent 6f5885a7
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -253,8 +253,8 @@ static int rvin_try_format(struct rvin_dev *vin, u32 which,
	int ret;

	sd_state = v4l2_subdev_alloc_state(sd);
	if (sd_state == NULL)
		return -ENOMEM;
	if (IS_ERR(sd_state))
		return PTR_ERR(sd_state);

	if (!rvin_format_from_pixel(vin, pix->pixelformat))
		pix->pixelformat = RVIN_DEFAULT_FORMAT;
+2 −2
Original line number Diff line number Diff line
@@ -676,9 +676,9 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity,
	 * rectangles.
	 */
	entity->config = v4l2_subdev_alloc_state(&entity->subdev);
	if (entity->config == NULL) {
	if (IS_ERR(entity->config)) {
		media_entity_cleanup(&entity->subdev.entity);
		return -ENOMEM;
		return PTR_ERR(entity->config);
	}

	return 0;
+2 −2
Original line number Diff line number Diff line
@@ -508,8 +508,8 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan,
		return -ENODEV;

	sd_state = v4l2_subdev_alloc_state(subdev);
	if (!sd_state)
		return -ENOMEM;
	if (IS_ERR(sd_state))
		return PTR_ERR(sd_state);
	/*
	 * Retrieve the format information and if requested format isn't
	 * supported, keep the current format.