From: Michael Grzeschik <mgr@pengutronix.de>
To: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Cc: Abhishek Tamboli <abhishektamboli9@gmail.com>,
dan.scally@ideasonboard.com, gregkh@linuxfoundation.org,
skhan@linuxfoundation.org, dan.carpenter@linaro.org,
rbmarliere@gmail.com,
linux-kernel-mentees@lists.linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] usb: gadget: uvc: Fix ERR_PTR dereference in uvc_v4l2.c
Date: Thu, 8 Aug 2024 22:51:30 +0200 [thread overview]
Message-ID: <ZrUv0tX7r0RuWLW2@pengutronix.de> (raw)
In-Reply-To: <20240802181841.GA21917@pendragon.ideasonboard.com>
[-- Attachment #1: Type: text/plain, Size: 2724 bytes --]
Hi Laurent,
On Fri, Aug 02, 2024 at 09:18:41PM +0300, Laurent Pinchart wrote:
>Hi Abhishek,
>
>(CC'ing Michael Grzeschik)
>
>Thank you for the patch.
>
>On Fri, Aug 02, 2024 at 11:32:47PM +0530, Abhishek Tamboli wrote:
>> Fix potential dereferencing of ERR_PTR() in find_format_by_pix()
>> and uvc_v4l2_enum_format().
>>
>> Fix the following smatch errors:
>>
>> drivers/usb/gadget/function/uvc_v4l2.c:124 find_format_by_pix()
>> error: 'fmtdesc' dereferencing possible ERR_PTR()
>> drivers/usb/gadget/function/uvc_v4l2.c:392 uvc_v4l2_enum_format()
>> error: 'fmtdesc' dereferencing possible ERR_PTR()
>>
>> Signed-off-by: Abhishek Tamboli <abhishektamboli9@gmail.com>
>> ---
>> drivers/usb/gadget/function/uvc_v4l2.c | 6 ++++++
>> 1 file changed, 6 insertions(+)
>>
>> diff --git a/drivers/usb/gadget/function/uvc_v4l2.c b/drivers/usb/gadget/function/uvc_v4l2.c
>> index a024aecb76dc..9dd602a742c4 100644
>> --- a/drivers/usb/gadget/function/uvc_v4l2.c
>> +++ b/drivers/usb/gadget/function/uvc_v4l2.c
>> @@ -121,6 +121,9 @@ static struct uvcg_format *find_format_by_pix(struct uvc_device *uvc,
>> list_for_each_entry(format, &uvc->header->formats, entry) {
>> const struct uvc_format_desc *fmtdesc = to_uvc_format(format->fmt);
>>
>> + if (IS_ERR(fmtdesc))
>> + continue;
>> +
>> if (fmtdesc->fcc == pixelformat) {
>> uformat = format->fmt;
>> break;
>> @@ -389,6 +392,9 @@ uvc_v4l2_enum_format(struct file *file, void *fh, struct v4l2_fmtdesc *f)
>> return -EINVAL;
>>
>> fmtdesc = to_uvc_format(uformat);
>> + if (IS_ERR(fmtdesc))
>> + return -EINVAL;
>> +
>> f->pixelformat = fmtdesc->fcc;
>>
>> return 0;
>
>Michael, you authored this, I'll let you review the patch and decide if
>this is a false positive.
Since the following patch was applied,
https://lore.kernel.org/all/20240221-uvc-gadget-configfs-guid-v1-1-f0678ca62ebb@pengutronix.de/
the issue is technically impossible to happen.
However the patch I mentioned was only applied recently and in all older
kernels someone could add a format into configfs that is not part of
uvc_format_desc from drivers/media/common/uvc.c and therefor can run
into the issue.
As this will also not hurt the current kernel I would like the patch
to be applied with the Tag:
Fixes: 588b9e8560 (usb: gadget: uvc: add v4l2 enumeration api calls)
Thanks,
Michael
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-08-08 21:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-02 18:02 [PATCH] usb: gadget: uvc: Fix ERR_PTR dereference in uvc_v4l2.c Abhishek Tamboli
2024-08-02 18:18 ` Laurent Pinchart
2024-08-08 20:51 ` Michael Grzeschik [this message]
2024-08-02 18:40 ` Dan Carpenter
2024-08-08 15:19 ` Abhishek Tamboli
2024-08-08 15:25 ` Abhishek Tamboli
2024-08-13 8:11 ` Greg KH
2024-08-13 16:15 ` Abhishek Tamboli
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=ZrUv0tX7r0RuWLW2@pengutronix.de \
--to=mgr@pengutronix.de \
--cc=abhishektamboli9@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=dan.scally@ideasonboard.com \
--cc=gregkh@linuxfoundation.org \
--cc=laurent.pinchart@ideasonboard.com \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rbmarliere@gmail.com \
--cc=skhan@linuxfoundation.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