mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] usb: gadget: fix null pointer dereference in usb_put_function_instance()
@ 2026-08-16  6:17 Jeffin Philip
  2026-08-27  4:37 ` Jeffin Philip
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffin Philip @ 2026-08-16  6:17 UTC (permalink / raw)
  To: gregkh
  Cc: jeffinphilip14, balbi, bigeasy, linux-usb, linux-kernel, stable,
	syzbot+fd6ef980cf1c722be639

usb_put_function_instance() attempts to dereference fd inside fi struct
to get mod in uvc_alloc_inst() error path. However, fd is not allocated
until later in try_get_usb_function_instance() after allocating fi in
uvc_alloc_inst() and thus guranteed to be null in error path. Fix this
by adding a null check for fi->fd that returns if fd is null.

Reported-by: syzbot+fd6ef980cf1c722be639@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=fd6ef980cf1c722be639
Fixes: 0062f6e56f70 ("usb: gadget: add a forward pointer from usb_function to its "instance"")
Cc: stable@vger.kernel.org
Signed-off-by: Jeffin Philip <jeffinphilip14@gmail.com>
---
 drivers/usb/gadget/functions.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/functions.c b/drivers/usb/gadget/functions.c
index 203361a64212..70e31c40e267 100644
--- a/drivers/usb/gadget/functions.c
+++ b/drivers/usb/gadget/functions.c
@@ -70,7 +70,7 @@ void usb_put_function_instance(struct usb_function_instance *fi)
 {
 	struct module *mod;
 
-	if (!fi)
+	if (!fi || !fi->fd)
 		return;
 
 	mod = fi->fd->mod;
-- 
2.55.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: fix null pointer dereference in usb_put_function_instance()
  2026-08-16  6:17 [PATCH] usb: gadget: fix null pointer dereference in usb_put_function_instance() Jeffin Philip
@ 2026-08-27  4:37 ` Jeffin Philip
  2026-08-27  5:03   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Jeffin Philip @ 2026-08-27  4:37 UTC (permalink / raw)
  To: jeffinphilip14
  Cc: balbi, bigeasy, gregkh, linux-kernel, linux-usb, stable,
	syzbot+fd6ef980cf1c722be639

On Sun, 16 Aug 2026 11:47:12 +0530, Jeffin Philip wrote:

>usb_put_function_instance() attempts to dereference fd inside fi struct
>to get mod in uvc_alloc_inst() error path. However, fd is not allocated
>until later in try_get_usb_function_instance() after allocating fi in
>uvc_alloc_inst() and thus guranteed to be null in error path. Fix this
>by adding a null check for fi->fd that returns if fd is null.

Friendly ping, let me know if you want me to fix anything.

Thanks.
Jeffin.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] usb: gadget: fix null pointer dereference in usb_put_function_instance()
  2026-08-27  4:37 ` Jeffin Philip
@ 2026-08-27  5:03   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2026-08-27  5:03 UTC (permalink / raw)
  To: Jeffin Philip
  Cc: balbi, bigeasy, linux-kernel, linux-usb, stable,
	syzbot+fd6ef980cf1c722be639

On Thu, Aug 27, 2026 at 10:07:46AM +0530, Jeffin Philip wrote:
> On Sun, 16 Aug 2026 11:47:12 +0530, Jeffin Philip wrote:
> 
> >usb_put_function_instance() attempts to dereference fd inside fi struct
> >to get mod in uvc_alloc_inst() error path. However, fd is not allocated
> >until later in try_get_usb_function_instance() after allocating fi in
> >uvc_alloc_inst() and thus guranteed to be null in error path. Fix this
> >by adding a null check for fi->fd that returns if fd is null.
> 
> Friendly ping, let me know if you want me to fix anything.

It's the middle of the merge window, we can't do anything until after
-rc1 is out.

In the meantime, please help review other patches on the list so that
yours rises to the top.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-27  5:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-16  6:17 [PATCH] usb: gadget: fix null pointer dereference in usb_put_function_instance() Jeffin Philip
2026-08-27  4:37 ` Jeffin Philip
2026-08-27  5:03   ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®