HomeFreeBSD

ibcore: Fix sysfs registration error flow

Description

ibcore: Fix sysfs registration error flow

The kernel commit cited below restructured ib device management
so that the device kobject is initialized in ib_alloc_device.

As part of the restructuring, the kobject is now initialized in
procedure ib_alloc_device, and is later added to the device hierarchy
in the ib_register_device call stack, in procedure
ib_device_register_sysfs (which calls device_add).

However, in the ib_device_register_sysfs error flow, if an error
occurs following the call to device_add, the cleanup procedure
device_unregister is called. This call results in the device object
being deleted -- which results in various use-after-free crashes.

The correct cleanup call is device_del -- which undoes device_add
without deleting the device object.

The device object will then (correctly) be deleted in the
ib_register_device caller's error cleanup flow, when the caller invokes
ib_dealloc_device.

Linux commit:
b312be3d87e4c80872cbea869e569175c5eb0f9a

PR: 264472
Sponsored by: NVIDIA Networking

(cherry picked from commit 55d183367104e3efcdaa936f65e4f82303871271)

Details

Provenance
hselaskyAuthored on Jun 21 2022, 9:07 AM
Parents
rGc253ae9fe423: iommu_gas: restrict tree search to promising paths
Branches
Unknown
Tags
Unknown