]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
media: v4l2-subdev: fix some NULL vs IS_ERR() checks
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 22 Jun 2021 14:31:53 +0000 (16:31 +0200)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 22 Jul 2021 12:01:54 +0000 (14:01 +0200)
The v4l2_subdev_alloc_state() function returns error pointers, it
doesn't return NULL.

Fixes: 0d346d2a6f54 ("media: v4l2-subdev: add subdev-wide state struct")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/platform/rcar-vin/rcar-v4l2.c
drivers/media/platform/vsp1/vsp1_entity.c
drivers/staging/media/tegra-video/vi.c

index cca15a10c0b34fddaecbffcb272f9f8ce365b7b7..0d141155f0e3ee00ba0a0a7c8868c0535135a603 100644 (file)
@@ -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;
index 6f51e5c755432480c491cfdf919f0d33cf5691f6..823c15facd1b4dd24d8c203d63e74c29dfe29634 100644 (file)
@@ -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;
index 89709cd06d4d36db14b94205d85314aa71d73968..d321790b07d9582804e15aeeac6e21d36907a576 100644 (file)
@@ -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.