mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: syzbot <syzbot+87ce68d9f48eca96a84a@syzkaller.appspotmail.com>
To: linux-kernel@vger.kernel.org
Subject: Forwarded: [PATCH] usb: fix memory leak in dev_set_name
Date: Sat, 26 Sep 2026 03:37:15 -0700	[thread overview]
Message-ID: <6ab7a05b.dc2998a4.2261f5.0054.GAE@google.com> (raw)
In-Reply-To: <6a7a06b7.b50370da.49fe0.0057.GAE@google.com>

For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.

***

Subject: [PATCH] usb: fix memory leak in dev_set_name
Author: drifabdelmalekmohamedsaid@gmail.com

#syz test

diff --git a/drivers/usb/gadget/legacy/raw_gadget.c
b/drivers/usb/gadget/legacy/raw_gadget.c
index 4febf8dac7ca..9c263950f609 100644
--- a/drivers/usb/gadget/legacy/raw_gadget.c
+++ b/drivers/usb/gadget/legacy/raw_gadget.c
@@ -327,9 +327,16 @@ static int gadget_bind(struct usb_gadget *gadget,

 static void gadget_unbind(struct usb_gadget *gadget)
 {
+       unsigned long flags;
        struct raw_dev *dev = get_gadget_data(gadget);

        set_gadget_data(gadget, NULL);
+
+       /*Avoid dangling pointer in case it remaining references*/
+       spin_lock_irqsave(&dev->lock, flags);
+       dev->gadget = NULL;
+       spin_unlock_irqrestore(&dev->lock, flags);
+
        /* Matches kref_get() in gadget_bind(). */
        kref_put(&dev->count, dev_free);
 }

      parent reply	other threads:[~2026-09-26 10:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-10 17:13 [syzbot] [kernel?] " syzbot
2026-08-11  4:04 ` Edward Adam Davis
2026-08-11 13:32   ` syzbot
2026-09-26 10:37 ` syzbot [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6ab7a05b.dc2998a4.2261f5.0054.GAE@google.com \
    --to=syzbot+87ce68d9f48eca96a84a@syzkaller.appspotmail.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®