Patch "usb: gadget: goku_udc: fix potential crashes in probe" has been added to the 4.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: gadget: goku_udc: fix potential crashes in probe

to the 4.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-gadget-goku_udc-fix-potential-crashes-in-probe.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1407b7f75ecc290d1a6ef2440de67cf5461e3d6c
Author: Evgeny Novikov <novikov@xxxxxxxxx>
Date:   Fri Oct 2 18:01:55 2020 +0300

    usb: gadget: goku_udc: fix potential crashes in probe
    
    [ Upstream commit 0d66e04875c5aae876cf3d4f4be7978fa2b00523 ]
    
    goku_probe() goes to error label "err" and invokes goku_remove()
    in case of failures of pci_enable_device(), pci_resource_start()
    and ioremap(). goku_remove() gets a device from
    pci_get_drvdata(pdev) and works with it without any checks, in
    particular it dereferences a corresponding pointer. But
    goku_probe() did not set this device yet. So, one can expect
    various crashes. The patch moves setting the device just after
    allocation of memory for it.
    
    Found by Linux Driver Verification project (linuxtesting.org).
    
    Reported-by: Pavel Andrianov <andrianov@xxxxxxxxx>
    Signed-off-by: Evgeny Novikov <novikov@xxxxxxxxx>
    Signed-off-by: Felipe Balbi <balbi@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c
index 1fdfec14a3ba1..5d4616061309e 100644
--- a/drivers/usb/gadget/udc/goku_udc.c
+++ b/drivers/usb/gadget/udc/goku_udc.c
@@ -1773,6 +1773,7 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 		goto err;
 	}
 
+	pci_set_drvdata(pdev, dev);
 	spin_lock_init(&dev->lock);
 	dev->pdev = pdev;
 	dev->gadget.ops = &goku_ops;
@@ -1806,7 +1807,6 @@ static int goku_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	}
 	dev->regs = (struct goku_udc_regs __iomem *) base;
 
-	pci_set_drvdata(pdev, dev);
 	INFO(dev, "%s\n", driver_desc);
 	INFO(dev, "version: " DRIVER_VERSION " %s\n", dmastr());
 	INFO(dev, "irq %d, pci mem %p\n", pdev->irq, base);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux