[lvc-project] [PATCH v1] usb: tegra-xudc: check ep and ep->desc before deref

Alexey V. Vissarionov gremlin at altlinux.org
Wed Apr 16 14:54:16 MSK 2025


Good ${greeting_time}!

On 2025-04-16 11:20:10 +0100, Jon Hunter wrote:

 >> +	/* trb_phys_to_virt() dereferences ep; check it here */
 >> +	if (!ep)
 >> +	{
 > Please make sure you run 'checkpatch.pl' as I am sure if will
 > flag that the above should be ...
 > if (!ep) {

ACK.

 >> +		dev_err(xudc->dev, "Unbelievable: ep is NULL\n");
 > I quite like the 'Unbelievable' but 'unexpected NULL pointer
 > for ep' is also fine.

ACK.

 >> +	/* tegra_xudc_req_done() dereferences ep->desc; check it
 >> here */
 >> +	if (!ep->desc)
 > I am not sure about the error message here, because the existing
 > code just skips this. So it is not clear if this can happen and
 > could be expected.

Now ep->desc is checked immediately after tegra_xudc_req_done(),
where it is dereferenced, so it was somehow expected. My suggestion
is just to check this expection earlier.

Next version of the patch follows.


-- 
Alexey V. Vissarionov
gremlin ПРИ altlinux ТЧК org; +vii-cmiii-ccxxix-lxxix-xlii
GPG: 0D92F19E1C0DC36E27F61A29CD17E2B43D879005 @ hkp://keys.gnupg.net



More information about the lvc-project mailing list