| .. | .. |
|---|
| 39 | 39 | return container_of(info, struct uio_pci_generic_dev, info); |
|---|
| 40 | 40 | } |
|---|
| 41 | 41 | |
|---|
| 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 | + |
|---|
| 42 | 58 | /* Interrupt handler. Read/modify/write the command register to disable |
|---|
| 43 | 59 | * the interrupt. */ |
|---|
| 44 | 60 | static irqreturn_t irqhandler(int irq, struct uio_info *info) |
|---|
| .. | .. |
|---|
| 78 | 94 | |
|---|
| 79 | 95 | gdev->info.name = "uio_pci_generic"; |
|---|
| 80 | 96 | gdev->info.version = DRIVER_VERSION; |
|---|
| 97 | + gdev->info.release = release; |
|---|
| 81 | 98 | gdev->pdev = pdev; |
|---|
| 82 | 99 | if (pdev->irq) { |
|---|
| 83 | 100 | gdev->info.irq = pdev->irq; |
|---|