Re: [PATCH] usb: dwc2: Fix error path in gadget registration

From: Minas Harutyunyan
Date: Tue Jul 14 2020 - 08:32:37 EST


Hi Marek,

On 7/14/2020 12:48 PM, Marek Szyprowski wrote:
> When gadget registration fails, one should not call usb_del_gadget_udc().
> Ensure this by setting gadget->udc to NULL. Also in case of a failure
I was able to reproduce issue. I'm Ok with this fix.

> there is no need to disable low-level hardware, so return immiedetly
> instead of jumping to error_init label.
>
Why do you think that disable low-level hardware not required which was
enabled before? Also for some platforms required to call
regulator_disable() which was enabled earlier in probe function.
So, I suggest to keep jump to error_init label.

> This fixes the following kernel NULL ptr dereference on gadget failure
> (can be easily triggered with g_mass_storage without any module
> parameters):
>

Thanks,
Minas