From: Oliver Neukum <oneukum@suse.com>
To: Greg KH <gregkh@linuxfoundation.org>,
Pawel Laszczak <pawell@cadence.com>
Cc: peter.chen@kernel.org, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] usb: cdnsp: Fixes error: uninitialized symbol 'len'
Date: Wed, 5 Apr 2023 19:41:53 +0200 [thread overview]
Message-ID: <ddba44b4-5c5c-0085-2678-9f8151811494@suse.com> (raw)
In-Reply-To: <2023040514-outspoken-librarian-3cde@gregkh>
On 05.04.23 19:23, Greg KH wrote:
> On Fri, Mar 31, 2023 at 05:06:00AM -0400, Pawel Laszczak wrote:
>> {
>> struct usb_ctrlrequest *ctrl = &pdev->setup;
>> - int ret = 0;
>> + int ret = -EINVAL;
>> u16 len;
>>
>> trace_cdnsp_ctrl_req(ctrl);
>> @@ -424,7 +424,6 @@ void cdnsp_setup_analyze(struct cdnsp_device *pdev)
>>
>> if (pdev->gadget.state == USB_STATE_NOTATTACHED) {
>> dev_err(pdev->dev, "ERR: Setup detected in unattached state\n");
>> - ret = -EINVAL;
>
> That's a nice change, but I don't see the original error here that you
> are saying this change fixes.
>
> What am I missing?
The function has this check at its beginning:
if (!pdev->gadget_driver)
goto out;
ret is initialized to 0 and len is uninitialized.
The jump goes to:
out:
if (ret < 0)
cdnsp_ep0_stall(pdev);
else if (!len && pdev->ep0_stage != CDNSP_STATUS_STAGE)
cdnsp_status_stage(pdev);
The compiler (and an analysis tool) can determine that len will be
evaluated in an uninitialized state. Setting ret to something
negative prevents that. I must say this is convoluted, even though
it is correct.
HTH
Oliver
next prev parent reply other threads:[~2023-04-05 17:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-31 9:06 [PATCH] usb: cdnsp: Fixes error: uninitialized symbol 'len' Pawel Laszczak
2023-04-05 17:23 ` Greg KH
2023-04-05 17:41 ` Oliver Neukum [this message]
2023-04-05 17:54 ` Greg KH
2023-04-06 5:33 ` Pawel Laszczak
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=ddba44b4-5c5c-0085-2678-9f8151811494@suse.com \
--to=oneukum@suse.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=pawell@cadence.com \
--cc=peter.chen@kernel.org \
--cc=stable@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