HomeFreeBSD

ibcore: Fix memory leak in cm_add/remove_one.

Description

ibcore: Fix memory leak in cm_add/remove_one.

In the process of moving the debug counters sysfs entries, the commit
mentioned below eliminated the cm_infiniband sysfs directory.

This sysfs directory was tied to the cm_port object allocated in procedure
cm_add_one().

Before the commit below, this cm_port object was freed via a call to
kobject_put(port->kobj) in procedure cm_remove_port_fs().

Since port no longer uses its kobj, kobject_put(port->kobj) was eliminated.
This, however, meant that kfree was never called for the cm_port buffers.

Fix this by adding explicit kfree(port) calls to functions cm_add_one()
and cm_remove_one().

Note that the kfree call in the first chunk below, in the cm_add_one error
flow, fixes an old, undetected memory leak.

Linux commit:
94635c36f3854934a46d9e812e028d4721bbb0e6

Reviewed by: kib
Sponsored by: Mellanox Technologies // NVIDIA Networking

(cherry picked from commit 8d04583de542dcd087b401f6b830b8e6ab43d696)

Details

Provenance
hselaskyAuthored on Jun 16 2021, 1:01 PM
Parents
rGa306f3d4485d: ibcore: Block processing of alternate path handling in RoCE RX CM messages.
Branches
Unknown
Tags
Unknown