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