From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: Jerry Liu <jerry.liu@technexion.com>
Cc: mchehab@kernel.org, linux-media@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] media: uvcvideo: Modified uvc_ctrl_fill_xu_info 'kmalloc' to 'kzalloc'
Date: Fri, 15 Sep 2023 22:04:49 +0300 [thread overview]
Message-ID: <20230915190449.GA12131@pendragon.ideasonboard.com> (raw)
In-Reply-To: <20230915161213.42503-1-jerry.liu@technexion.com>
Hi Jerry,
Thank you for the patch.
On Fri, Sep 15, 2023 at 09:12:14AM -0700, Jerry Liu wrote:
> If the request length of UVC XU is 1 (even though this is illegal), due
> to 'data' may be the non-zero value, UVC_GET_LEN could potentially result
> in a length that is not 1 because of the high byte is not zero. In order
> to ensure that 2-byte data array is set to 0, 'kmalloc' is modified to 'kzalloc'.
I don't think this can happen. The call to uvc_query_ctrl(UVC_GET_LEN)
is given a length of 2. If the device responds with less than two bytes,
the function will return an error, and uvc_ctrl_fill_xu_info() will
propagate the error to the caller, without accessing the data array.
>
> Signed-off-by: Jerry Liu <jerry.liu@technexion.com>
> ---
> drivers/media/usb/uvc/uvc_ctrl.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c
> index 5e9d3da862dd..054bc14f7a58 100644
> --- a/drivers/media/usb/uvc/uvc_ctrl.c
> +++ b/drivers/media/usb/uvc/uvc_ctrl.c
> @@ -2088,7 +2088,7 @@ static int uvc_ctrl_fill_xu_info(struct uvc_device *dev,
> u8 *data;
> int ret;
>
> - data = kmalloc(2, GFP_KERNEL);
> + data = kzalloc(2, GFP_KERNEL);
> if (data == NULL)
> return -ENOMEM;
>
--
Regards,
Laurent Pinchart
next prev parent reply other threads:[~2023-09-15 19:05 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 16:12 Jerry Liu
2023-09-15 19:04 ` Laurent Pinchart [this message]
2023-09-20 2:27 ` Jerry Liu
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=20230915190449.GA12131@pendragon.ideasonboard.com \
--to=laurent.pinchart@ideasonboard.com \
--cc=jerry.liu@technexion.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@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
all inboxes | Powered by JetHome®