Skip to contentSkip to conversation

HID: intel-ish-hid: ipc: Fix dev_err usage with uninitialized dev->devc

PATCH In review Zhang, Lixu 3 participants 3 messages Mar 6, 2024 – Mar 21, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 HID: intel-ish-hid: ipc: Fix dev_err usage with uninitialized dev->devc

From: Zhang Lixu <[email protected]>

The variable dev->devc in ish_dev_init was utilized by dev_err before it was properly assigned. To rectify this, the assignment of dev->devc has been moved to immediately follow memory allocation.

Without this change "(NULL device *)" is printed for device information.

Fixes 8ae2f2b0a284 ("HID: intel-ish-hid: ipc: Fix potential use-after-free in work function")
Fixes ae02e5d40d5f ("HID: intel-ish-hid: ipc layer")
---
 drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/intel-ish-hid/ipc/ipc.c +1 -1
index 7cc412798fdf..adce30f8ebff 100644
@@ -948,6 +948,7 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
 	if (!dev)
 		return NULL;
 
+	dev->devc = &pdev->dev;
 	ishtp_device_init(dev);
 
 	init_waitqueue_head(&dev->wait_hw_ready);
@@ -983,7 +984,6 @@ struct ishtp_device *ish_dev_init(struct pci_dev *pdev)
 	}
 
 	dev->ops = &ish_hw_ops;
-	dev->devc = &pdev->dev;
 	dev->mtu = IPC_PAYLOAD_SIZE - sizeof(struct ishtp_msg_hdr);
 	return dev;
 }
Signature · 1 line
2.40.1
#1 lore raw
Quoted 11 lines · Lixu

From: Zhang Lixu <[email protected]>

The variable dev->devc in ish_dev_init was utilized by dev_err before it
was properly assigned. To rectify this, the assignment of dev->devc has
been moved to immediately follow memory allocation.

Without this change "(NULL device *)" is printed for device information.

Quoted 6 lines
Fixes 8ae2f2b0a284 ("HID: intel-ish-hid: ipc: Fix potential use-

after-free in work function")

Fixes ae02e5d40d5f ("HID: intel-ish-hid: ipc layer")

---

This is not an important change to submit to rc cycle. This is just a logging issue.

Thanks,
Srinivas

Quoted 26 lines

 drivers/hid/intel-ish-hid/ipc/ipc.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/intel- renamed from drivers/hid/intel-ish-hid/ipc/ipc.c +0 -0

ish-hid/ipc/ipc.c
index 7cc412798fdf..adce30f8ebff 100644

drivers/hid/intel-ish-hid/ipc/ipc.c +0 -0
@@ -948,6 +948,7 @@ struct ishtp_device *ish_dev_init(struct pci_dev
 *pdev)
         if (!dev)
                 return NULL;


+       dev->devc = &pdev->dev;
        ishtp_device_init(dev);

        init_waitqueue_head(&dev->wait_hw_ready);

drivers/hid/intel-ish-hid/ipc/ipc.c +0 -0
@@ -983,7 +984,6 @@ struct ishtp_device *ish_dev_init(struct pci_dev
 *pdev)
         }


        dev->ops = &ish_hw_ops;
-       dev->devc = &pdev->dev;
        dev->mtu = IPC_PAYLOAD_SIZE - sizeof(struct ishtp_msg_hdr); return dev;
 }

maintainer
#2 lore raw
Quoted 7 lines · srinivas pandruvada
Quoted 7 lines

The variable dev->devc in ish_dev_init was utilized by dev_err before it was properly assigned. To rectify this, the assignment of dev->devc has been moved to immediately follow memory allocation.

Without this change "(NULL device *)" is printed for device information.

Quoted 8 lines
Quoted 6 lines
Fixes 8ae2f2b0a284 ("HID: intel-ish-hid: ipc: Fix potential use-

after-free in work function")

Fixes ae02e5d40d5f ("HID: intel-ish-hid: ipc layer")

---

This is not an important change to submit to rc cycle. This is just a logging issue.

Agreed about the severity. However it fixes a user-visible issue and doesn't have a potential to cause any regression, so I have just queued it in hid.git#for-6.9/upstream-fixes nevertheless.

Thanks,

Signature · 2 lines
Jiri Kosina
SUSE Labs