hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/uio/uio_pci_generic.c
....@@ -39,6 +39,22 @@
3939 return container_of(info, struct uio_pci_generic_dev, info);
4040 }
4141
42
+static int release(struct uio_info *info, struct inode *inode)
43
+{
44
+ struct uio_pci_generic_dev *gdev = to_uio_pci_generic_dev(info);
45
+
46
+ /*
47
+ * This driver is insecure when used with devices doing DMA, but some
48
+  * people (mis)use it with such devices.
49
+  * Let's at least make sure DMA isn't left enabled after the userspace
50
+  * driver closes the fd.
51
+  * Note that there's a non-zero chance doing this will wedge the device
52
+  * at least until reset.
53
+ */
54
+ pci_clear_master(gdev->pdev);
55
+ return 0;
56
+}
57
+
4258 /* Interrupt handler. Read/modify/write the command register to disable
4359 * the interrupt. */
4460 static irqreturn_t irqhandler(int irq, struct uio_info *info)
....@@ -78,6 +94,7 @@
7894
7995 gdev->info.name = "uio_pci_generic";
8096 gdev->info.version = DRIVER_VERSION;
97
+ gdev->info.release = release;
8198 gdev->pdev = pdev;
8299 if (pdev->irq) {
83100 gdev->info.irq = pdev->irq;