mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil@xs4all.nl>
To: Yizhuo <yzhai003@ucr.edu>
Cc: csong@cs.ucr.edu, zhiyunq@cs.ucr.edu,
	Mike Isely <isely@pobox.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [media] pvrusb2: qctrl.flag will be uninitlaized if cx2341x_ctrl_query() returns error code
Date: Mon, 26 Aug 2019 14:08:52 +0200	[thread overview]
Message-ID: <afa0a08e-30ff-7958-fb09-3e3d58d47f0e@xs4all.nl> (raw)
In-Reply-To: <20190821210931.9621-1-yzhai003@ucr.edu>

On 8/21/19 11:09 PM, Yizhuo wrote:
> Inside function ctrl_cx2341x_getv4lflags(), qctrl.flag
> will be uninitlaized if cx2341x_ctrl_query() returns -EINVAL.
> However, it will be used in the later if statement, which is
> potentially unsafe.
> 
> Signed-off-by: Yizhuo <yzhai003@ucr.edu>
> ---
>  drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> index ad5b25b89699..1fa05971316a 100644
> --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c
> @@ -793,6 +793,7 @@ static unsigned int ctrl_cx2341x_getv4lflags(struct pvr2_ctrl *cptr)
>  	struct v4l2_queryctrl qctrl;
>  	struct pvr2_ctl_info *info;
>  	qctrl.id = cptr->info->v4l_id;
> +	memset(&qctr, 0, sizeof(qctrl))

Please compile test your patches! This doesn't compile due to a typo
(qctr -> qctrl).

Also, this would overwrite qctrl.id with 0, not what you want.

Instead, just do:

  	struct v4l2_queryctrl qctrl = {};

to initialize the struct with all 0.

Regards,

	Hans

>  	cx2341x_ctrl_query(&cptr->hdw->enc_ctl_state,&qctrl);
>  	/* Strip out the const so we can adjust a function pointer.  It's
>  	   OK to do this here because we know this is a dynamically created
> 


  parent reply	other threads:[~2019-08-26 12:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-21 21:09 Yizhuo
2019-08-23  1:31 ` kbuild test robot
2019-08-25 17:47 ` isely
2019-08-26 12:08 ` Hans Verkuil [this message]
2019-08-26 23:32   ` Yizhuo Zhai
2019-08-26 23:55 Yizhuo
2019-08-26 23:56 ` isely

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=afa0a08e-30ff-7958-fb09-3e3d58d47f0e@xs4all.nl \
    --to=hverkuil@xs4all.nl \
    --cc=csong@cs.ucr.edu \
    --cc=isely@pobox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=yzhai003@ucr.edu \
    --cc=zhiyunq@cs.ucr.edu \
    /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

all inboxes | Powered by JetHome®