The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Lovekesh Solanki <lovekeshsolanki00@gmail.com>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: jjy600901@snu.ac.kr, brauner@kernel.org, eulgyukim@snu.ac.kr,
	 gregkh@linuxfoundation.org, jack@suse.cz, kees@kernel.org,
	linux-kernel@vger.kernel.org,  linux-usb@vger.kernel.org,
	mjguzik@gmail.com, viro@zeniv.linux.org.uk,
	 stable@vger.kernel.org
Subject: Re: [PATCH] USB: gadget: fix NULL pointer dereference in gadget_dev_ioctl()
Date: Tue, 25 Aug 2026 19:59:43 +0530	[thread overview]
Message-ID: <ao2mZdrHdkRTypkU@eggarch> (raw)
In-Reply-To: <903f6c28-57f1-4aa2-a111-910fcfbee52b@rowland.harvard.edu>

Thanks for the review,

On Tue, Aug 25, 2026 at 09:14:37AM -0400, Alan Stern wrote:
> Why does it matter that you read dev->gadget before the state check 
> rather than after?  If it doesn't matter, there's no reason to mention 
> it in the patch description.
The order of reading it doesn't matter. The important part is to read it
while holding the lock, perhaps the wording is unclear, I'll reword it
in v2.

> Also, why does it matter that gadgetfs_bind() writes dev->gadget without 
> holding the lock?  Again, the description shouldn't mention things that 
> don't matter.
Because ioctl can get a stale dev->gadget before dev->lock, while
dev->state is checked after acquiring the lock, which is the cause.
Is the reference to gadgetfs_bind() unncessary? Or this part of the
explanation is irrelvant?

> Why did you add this test for gadget being non-NULL?  Is there any way 
> it could possibly be NULL at this point?
It seems it doesn't matter since if read is correct it can't be NULL, it
was an initial attempt to fix but its unnecessary now, I'll remove that
as well.

Regards,
Lovekesh

  reply	other threads:[~2026-08-25 14:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-24 11:35 [BUG] general protection fault in gadget_dev_ioctl Jaeyoung Chung
2026-08-25 10:58 ` [PATCH] USB: gadget: fix NULL pointer dereference in gadget_dev_ioctl() Lovekesh Solanki
2026-08-25 11:07   ` Lovekesh Solanki
2026-08-25 13:14   ` Alan Stern
2026-08-25 14:29     ` Lovekesh Solanki [this message]
2026-08-25 15:40       ` Alan Stern
2026-08-25 17:16         ` Lovekesh Solanki
  -- strict thread matches above, loose matches on Subject: below --
2026-08-24 16:00 [BUG] general protection fault in path_put Jaeyoung Chung
2026-08-25 10:46 ` [PATCH] USB: gadget: fix NULL pointer dereference in gadget_dev_ioctl() Lovekesh Solanki
2026-08-25 11:15   ` Lovekesh Solanki

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=ao2mZdrHdkRTypkU@eggarch \
    --to=lovekeshsolanki00@gmail.com \
    --cc=brauner@kernel.org \
    --cc=eulgyukim@snu.ac.kr \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=jjy600901@snu.ac.kr \
    --cc=kees@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=viro@zeniv.linux.org.uk \
    /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