public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Zhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com>
Cc: rafael@kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] device_core: check null pointer
Date: Sat, 15 Nov 2025 15:16:43 -0500	[thread overview]
Message-ID: <2025111523-preface-scoreless-b478@gregkh> (raw)
In-Reply-To: <20251114141821.416835-1-xiazhengqiao@huaqin.corp-partner.google.com>

On Fri, Nov 14, 2025 at 10:18:21PM +0800, Zhengqiao Xia wrote:
> Add null pointer check to avoid null pointer.
> When the USB device's interface is disabled, 'device_add' will not
> be called, and 'dev->p' will be NULL.

Wait, how does that happen?  Shouldn't we prevent that?

> When you use 'usbdev_ioctl' to
> call this USB interface at this point,'__device_attach' will be invoked.
> Then a null pointer will be generated.
> 
> Signed-off-by: Zhengqiao Xia <xiazhengqiao@huaqin.corp-partner.google.com>

Not a valid email address :( 

> ---
>  drivers/base/dd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/base/dd.c b/drivers/base/dd.c
> index 3328101e0e106..cfdeb420fd12a 100644
> --- a/drivers/base/dd.c
> +++ b/drivers/base/dd.c
> @@ -1033,7 +1033,7 @@ static int __device_attach(struct device *dev, bool allow_async)
>  	bool async = false;
>  
>  	device_lock(dev);
> -	if (dev->p->dead) {
> +	if (dev->p && dev->p->dead) {

If dev->p is NULL here, something else went wrong with the caller,
please, let's fix the root problem here instead.

What suddenly changed to cause this to happen?

thanks,

greg k-h

  reply	other threads:[~2025-11-15 20:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-14 14:18 [PATCH] device_core: check null pointer Zhengqiao Xia
2025-11-15 20:16 ` Greg KH [this message]
2025-11-17  2:55   ` Zhengqiao Xia
2025-11-17 12:37     ` Greg KH
2025-11-18  7:31       ` Zhengqiao Xia
2025-11-27  9:54         ` Greg KH
2025-11-27 11:37           ` Zhengqiao Xia
2025-11-27 11:51             ` Greg KH
2025-11-27 12:34               ` Zhengqiao Xia
2025-11-27 12:42                 ` Greg KH
2025-11-27 12:51                   ` Zhengqiao Xia

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=2025111523-preface-scoreless-b478@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=xiazhengqiao@huaqin.corp-partner.google.com \
    /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