kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>,
	Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Sakari Ailus <sakari.ailus@linux.intel.com>,
	linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] media: v4l2-subdev: fix some NULL vs IS_ERR() checks
Date: Tue, 22 Jun 2021 18:08:30 +0300	[thread overview]
Message-ID: <YNH87qd4eJOR296R@pendragon.ideasonboard.com> (raw)
In-Reply-To: <YNH0WU7BcQ/60UNG@mwanda>

Hi Dan,

Thank you for the patch.

On Tue, Jun 22, 2021 at 05:31:53PM +0300, Dan Carpenter wrote:
> The v4l2_subdev_alloc_state() function returns error pointers, it
> doesn't return NULL.

It's funny you send this patch today, I've been thinking about the exact
same issue yesterday, albeit more globally, when trying to figure out if
a function I called returned NULL or an error pointer on error.

Would it make to create an __err_ptr annotation to mark functions that
return an error pointer ? This would both give a simple indication to
the user and allow tools such as smatch to detect errors.

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

Mauro, can you pick this patch up ?

> ---
>  drivers/media/platform/vsp1/vsp1_entity.c | 4 ++--
>  drivers/staging/media/tegra-video/vi.c | 4 ++--
>  drivers/media/platform/rcar-vin/rcar-v4l2.c | 4 ++--
>  3 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c
> index 6f51e5c75543..823c15facd1b 100644
> --- a/drivers/media/platform/vsp1/vsp1_entity.c
> +++ b/drivers/media/platform/vsp1/vsp1_entity.c
> @@ -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;
> diff --git a/drivers/staging/media/tegra-video/vi.c b/drivers/staging/media/tegra-video/vi.c
> index 89709cd06d4d..d321790b07d9 100644
> --- a/drivers/staging/media/tegra-video/vi.c
> +++ b/drivers/staging/media/tegra-video/vi.c
> @@ -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.
> diff --git a/drivers/media/platform/rcar-vin/rcar-v4l2.c b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> index cca15a10c0b3..0d141155f0e3 100644
> --- a/drivers/media/platform/rcar-vin/rcar-v4l2.c
> +++ b/drivers/media/platform/rcar-vin/rcar-v4l2.c
> @@ -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;

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2021-06-22 15:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 14:31 Dan Carpenter
2021-06-22 15:08 ` Laurent Pinchart [this message]
2021-06-22 15:58   ` Dan Carpenter
2021-06-23  2:29     ` weiyongjun (A)
2021-06-23  2:34     ` Laurent Pinchart
2021-06-23  9:03       ` Dan Carpenter
2021-06-23 12:56         ` Laurent Pinchart
2021-06-22 20:01 ` Sakari Ailus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YNH87qd4eJOR296R@pendragon.ideasonboard.com \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=dan.carpenter@oracle.com \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kieran.bingham+renesas@ideasonboard.com \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sakari.ailus@linux.intel.com \
    --cc=tomi.valkeinen@ideasonboard.com \
    --subject='Re: [PATCH] media: v4l2-subdev: fix some NULL vs IS_ERR() checks' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).