diff mbox series

[RESEND,2/4] usb: musb: Fix NULL check on struct musb_request field

Message ID 20201027164200.18602-3-paul@crapouillou.net
State Superseded
Headers show
Series MUSB and jz4740-musb fixes | expand

Commit Message

Paul Cercueil Oct. 27, 2020, 4:41 p.m. UTC
The 'request' variable is a pointer to the 'request' field of the
struct musb_request 'req' pointer. It only worked until now because
the 'request' field is the first one in the musb_request structure, but
as soon as that changes, the check will be invalid.

Fix it preventively by doing the NULL-check on the 'req' pointer
instead.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Suggested-by: Maarten ter Huurne <maarten@treewalker.org>
---
 drivers/usb/musb/musb_gadget.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Tony Lindgren Oct. 29, 2020, 2:58 p.m. UTC | #1
* Paul Cercueil <paul@crapouillou.net> [201027 16:42]:
> The 'request' variable is a pointer to the 'request' field of the

> struct musb_request 'req' pointer. It only worked until now because

> the 'request' field is the first one in the musb_request structure, but

> as soon as that changes, the check will be invalid.

> 

> Fix it preventively by doing the NULL-check on the 'req' pointer

> instead.


Acked-by: Tony Lindgren <tony@atomide.com>
diff mbox series

Patch

diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c
index f62ffaede1ab..ef374d4dd94a 100644
--- a/drivers/usb/musb/musb_gadget.c
+++ b/drivers/usb/musb/musb_gadget.c
@@ -451,7 +451,7 @@  void musb_g_tx(struct musb *musb, u8 epnum)
 		return;
 	}
 
-	if (request) {
+	if (req) {
 
 		trace_musb_req_tx(req);