[PATCH][2.4.27-rc3] cardbus.c pointer truncation bug on 64-bitters

From: Mikael Pettersson
Date: Wed Jul 07 2004 - 15:56:42 EST


The 2.4 kernel's drivers/pcmcia/cardbus.c generates this compilation warning:

cardbus.c:239: warning: implicit declaration of function `pci_scan_device_Raceae718'
cardbus.c:239: warning: assignment makes pointer from integer without a cast

pci_scan_device() returns pci_dev*, but has no prototype in <linux/pci.h>.
At the call site in cardbus.c (the only one not in pci.c), the compiler
must assume an 'int' return value and store that in a pci_dev* variable.
On a 64-bit machine with 32-bit int, this destroys the high 32 bits of
the original pointer.

Trivial fix for 2.4.27-rc3 below.

Signed-off-by: Mikael Pettersson <mikpe@xxxxxxxxx>

diff -ruN linux-2.4.27-rc3/include/linux/pci.h linux-2.4.27-rc3.cardbus-64bit-fix/include/linux/pci.h
--- linux-2.4.27-rc3/include/linux/pci.h 2004-07-07 21:45:19.000000000 +0200
+++ linux-2.4.27-rc3.cardbus-64bit-fix/include/linux/pci.h 2004-07-07 21:48:53.000000000 +0200
@@ -595,6 +595,7 @@
int pci_bus_exists(const struct list_head *list, int nr);
struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);
struct pci_bus *pci_alloc_primary_bus(int bus);
+struct pci_dev *pci_scan_device(struct pci_dev *temp);
struct pci_dev *pci_scan_slot(struct pci_dev *temp);
int pci_proc_attach_device(struct pci_dev *dev);
int pci_proc_detach_device(struct pci_dev *dev);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/