linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tsuchiya Yuto <kitakar@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [bug report] media: atomisp: add NULL check for asd obtained from atomisp_video_pipe
Date: Wed, 01 Dec 2021 23:28:43 +0900	[thread overview]
Message-ID: <0d2058ff36dd15cd4475d42891f1f7058db9cb6e.camel@gmail.com> (raw)
In-Reply-To: <20211122074122.GA6581@kili>

On Mon, 2021-11-22 at 10:41 +0300, Dan Carpenter wrote:
> Hello Tsuchiya Yuto,
> 
> This is a semi-automatic email about new static checker warnings.
> 
> The patch c10bcb13462e: "media: atomisp: add NULL check for asd 
> obtained from atomisp_video_pipe" from Oct 18, 2021, leads to the 
> following Smatch complaint:
> 
> drivers/staging/media/atomisp/pci/atomisp_ioctl.c:1188 __atomisp_reqbufs()
> warn: variable dereferenced before check 'asd' (see line 1185)
> drivers/staging/media/atomisp/pci/atomisp_cmd.c:5192 atomisp_set_fmt_to_isp()
> warn: variable dereferenced before check 'asd' (see line 5188)
> 
> drivers/staging/media/atomisp/pci/atomisp_ioctl.c
>   1175  int __atomisp_reqbufs(struct file *file, void *fh,
>   1176                        struct v4l2_requestbuffers *req)
>   1177  {
>   1178          struct video_device *vdev = video_devdata(file);
>   1179          struct atomisp_video_pipe *pipe = atomisp_to_video_pipe(vdev);
>   1180          struct atomisp_sub_device *asd = pipe->asd;
>   1181          struct ia_css_frame_info frame_info;
>   1182          struct ia_css_frame *frame;
>   1183          struct videobuf_vmalloc_memory *vm_mem;
>   1184		u16 source_pad = atomisp_subdev_source_pad(vdev);
>   1185		u16 stream_id = atomisp_source_pad_to_stream_id(asd, source_pad);
>                                                                 ^^^
> There is an unchecked dereference inside this function.
> 
>   1186		int ret = 0, i = 0;
>   1187	
>   1188		if (!asd) {
>                     ^^^^
> This new check is too late.
> 
>   1189			dev_err(pipe->isp->dev, "%s(): asd is NULL, device is %s\n",
>   1190				__func__, vdev->name);
> 
> atomisp_set_fmt_to_isp() has the same thing.
> 
> regards,
> dan carpenter

Hello, thank you for pointing out this issue! For the record, patch sent
as:

	https://lore.kernel.org/linux-media/20211201141904.47231-1-kitakar@gmail.com/
	("media: atomisp: fix "variable dereferenced before check 'asd'"")

Regards,
Tsuchiya Yuto

      reply	other threads:[~2021-12-01 14:29 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-22  7:41 [bug report] media: atomisp: add NULL check for asd obtained from atomisp_video_pipe Dan Carpenter
2021-12-01 14:28 ` Tsuchiya Yuto [this message]

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=0d2058ff36dd15cd4475d42891f1f7058db9cb6e.camel@gmail.com \
    --to=kitakar@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=linux-media@vger.kernel.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).