Skip to contentSkip to conversation

PATCH: Make the SCAN_HWIF/UNREGISTER_HWIF stuff private

PATCH Alan Cox 1 participant 1 message Aug 17, 2004 libata

lore
Share & tools
lore

Alan Cox

author
#0 lore raw

Until we can kill these off here is a simple change that removes the pci_dev check and just stops users unloading interfaces not created by SCAN_HWIF. That cleans up all the unloading of hotplug device corner cases and stops users breaking things by killing live non generic devices.

Not sure what your current code looks like but a variant of the theory should apply to any version of the code independantly.

linux/ide.h renamed from linux/ide.h~ +1 -0
@@ -982,6 +982,7 @@
 	unsigned	present    : 1;	/* this interface exists logically (ie users) */
 	unsigned	configured : 1;	/* this hwif exists and is set up (may not be "present") */
 	unsigned	hold       : 1; /* this interface is always present */
+	unsigned	user_dev   : 1; /* user ioctl created device */
 	unsigned	serialized : 1;	/* serialized all channel operation */
 	unsigned	sharing_irq: 1;	/* 1 = sharing irq with another hwif */
 	unsigned	reset      : 1;	/* reset after probe */
ide/ide.c renamed from ide/ide.c~ +4 -2
@@ -1796,6 +1796,7 @@
 		case HDIO_SCAN_HWIF:
 		{
 			hw_regs_t hw;
+			ide_hwif_t *hwif;
 			int args[3];
 			if (!capable(CAP_SYS_RAWIO)) return -EACCES;
 			if (copy_from_user(args, p, 3 * sizeof(int)))
@@ -1804,15 +1805,16 @@
 			ide_init_hwif_ports(&hw, (unsigned long) args[0],
 					    (unsigned long) args[1], NULL);
 			hw.irq = args[2];
-			if (ide_register_hw(&hw, NULL) == -1)
+			if (ide_register_hw(&hw, &hwif) == -1)
 				return -EIO;
+			hwif->user_dev = 1;
 			return 0;
 		}
 	        case HDIO_UNREGISTER_HWIF:
 			if (!capable(CAP_SYS_RAWIO)) return -EACCES;
 			if(arg > MAX_HWIFS || arg < 0)
 				return -EINVAL;
-			if(ide_hwifs[arg].pci_dev)
+			if(!ide_hwifs[arg].user_dev)
 				return -EINVAL;
 			return ide_unregister_hwif(&ide_hwifs[arg]);
 		case HDIO_SET_NICE: