Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F147627809
D50154.id155219.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D50154.id155219.diff
View Options
diff --git a/sys/compat/linuxkpi/common/src/linux_pci.c b/sys/compat/linuxkpi/common/src/linux_pci.c
--- a/sys/compat/linuxkpi/common/src/linux_pci.c
+++ b/sys/compat/linuxkpi/common/src/linux_pci.c
@@ -309,9 +309,18 @@
spin_lock_destroy(&dev->devres_lock);
}
-static void
+static int
lkpifill_pci_dev(device_t dev, struct pci_dev *pdev)
{
+ int error;
+
+ error = kobject_init_and_add(&pdev->dev.kobj, &linux_dev_ktype,
+ &linux_root_device.kobj, device_get_nameunit(dev));
+ if (error != 0) {
+ printf("%s:%d: kobject_init_and_add returned %d\n",
+ __func__, __LINE__, error);
+ return (error);
+ }
pdev->devfn = PCI_DEVFN(pci_get_slot(dev), pci_get_function(dev));
pdev->vendor = pci_get_vendor(dev);
@@ -341,12 +350,10 @@
pdev->msi_desc = malloc(pci_msi_count(dev) *
sizeof(*pdev->msi_desc), M_DEVBUF, M_WAITOK | M_ZERO);
- kobject_init(&pdev->dev.kobj, &linux_dev_ktype);
- kobject_set_name(&pdev->dev.kobj, device_get_nameunit(dev));
- kobject_add(&pdev->dev.kobj, &linux_root_device.kobj,
- kobject_name(&pdev->dev.kobj));
spin_lock_init(&pdev->dev.devres_lock);
INIT_LIST_HEAD(&pdev->dev.devres_head);
+
+ return (0);
}
static void
@@ -374,9 +381,14 @@
lkpinew_pci_dev(device_t dev)
{
struct pci_dev *pdev;
+ int error;
pdev = malloc(sizeof(*pdev), M_DEVBUF, M_WAITOK|M_ZERO);
- lkpifill_pci_dev(dev, pdev);
+ error = lkpifill_pci_dev(dev, pdev);
+ if (error != 0) {
+ free(pdev, M_DEVBUF);
+ return (NULL);
+ }
pdev->dev.release = lkpinew_pci_dev_release;
return (pdev);
@@ -525,7 +537,10 @@
device_set_ivars(dev, dinfo);
}
- lkpifill_pci_dev(dev, pdev);
+ error = lkpifill_pci_dev(dev, pdev);
+ if (error != 0)
+ return (error);
+
if (isdrm)
PCI_GET_ID(device_get_parent(parent), parent, PCI_ID_RID, &rid);
else
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Mar 13, 10:54 AM (17 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29620032
Default Alt Text
D50154.id155219.diff (1 KB)
Attached To
Mode
D50154: LinuxKPI: pci: deal with kobject_add() being able to fail
Attached
Detach File
Event Timeline
Log In to Comment