Skip to contentSkip to conversation

mmc: ushc: fix NULL-deref at probe

PATCH Applied Johan Hovold 2 participants 2 messages Mar 13, 2017 – Mar 16, 2017

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

PATCH 1/1 mmc: ushc: fix NULL-deref at probe

Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.

Fixes 53f3a9e26ed5 ("mmc: USB SD Host Controller (USHC) driver")
Cc stable <[email protected]> # 2.6.37
Cc David Vrabel <[email protected]>
---
 drivers/mmc/host/ushc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/host/ushc.c +3 -0
index d2c386f09d69..1d843357422e 100644
@@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
 	struct ushc_data *ushc;
 	int ret;
 
+	if (intf->cur_altsetting->desc.bNumEndpoints < 1)
+		return -ENODEV;
+
 	mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev);
 	if (mmc == NULL)
 		return -ENOMEM;
Signature · 1 line
2.12.0
Applied
#1 lore raw
Quoted 7 lines · Johan Hovold

Make sure to check the number of endpoints to avoid dereferencing a NULL-pointer should a malicious device lack endpoints.

Fixes 53f3a9e26ed5 ("mmc: USB SD Host Controller (USHC) driver")
Cc stable <[email protected]> # 2.6.37
Cc David Vrabel <[email protected]>

Thanks, applied for fixes!

Kind regards
Uffe

Quoted 21 lines
---
 drivers/mmc/host/ushc.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/mmc/host/ushc.c +3 -1
index d2c386f09d69..1d843357422e 100644
@@ -426,6 +426,9 @@ static int ushc_probe(struct usb_interface *intf, const struct usb_device_id *id
        struct ushc_data *ushc;
        int ret;
 
+       if (intf->cur_altsetting->desc.bNumEndpoints < 1)
+               return -ENODEV;
+
        mmc = mmc_alloc_host(sizeof(struct ushc_data), &intf->dev);
        if (mmc == NULL)
                return -ENOMEM;
--

2.12.0