public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] device_core: check null pointer
@ 2025-11-14 14:18 Zhengqiao Xia
  2025-11-15 20:16 ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Zhengqiao Xia @ 2025-11-14 14:18 UTC (permalink / raw)
  To: gregkh, rafael; +Cc: linux-kernel, Zhengqiao Xia

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. 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>
---
 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) {
 		goto out_unlock;
 	} else if (dev->driver) {
 		if (device_is_bound(dev)) {
-- 
2.34.1


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

end of thread, other threads:[~2025-11-27 12:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-14 14:18 [PATCH] device_core: check null pointer Zhengqiao Xia
2025-11-15 20:16 ` Greg KH
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

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