summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorGuangshuo Li <lgs201920130244@gmail.com>2026-05-18 10:19:10 +0800
committerJason Gunthorpe <jgg@nvidia.com>2026-05-25 11:25:17 -0300
commit9a8826fdfbcd7ed2ccf745f5d54208358d939def (patch)
tree2252b8c5f63c3195c7f642e32b7d36cbe8bbb30e /include
parent35744ab3d03c5fca8c1752f53fc8fc674e14c561 (diff)
IB/mlx4: Fix refcount leak in add_port() error path
After kobject_init_and_add(), the lifetime of the embedded struct kobject is expected to be managed through the kobject core reference counting. In add_port(), failure paths after kobject_init_and_add() must not free struct mlx4_port directly, because the embedded kobject is then managed by the kobject core. Freeing it directly leaves the kobject reference counting unbalanced and can lead to incorrect lifetime handling. Allocate the pkey and gid attribute arrays before kobject_init_and_add(), so failures before kobject initialization can be handled by directly freeing the allocated memory. Once kobject_init_and_add() has been called, unwind later failures by removing any successfully created sysfs groups, calling kobject_del(), and then releasing the embedded kobject with kobject_put(). Fixes: c1e7e466120b ("IB/mlx4: Add iov directory in sysfs under the ib device") Link: https://patch.msgid.link/r/20260518021910.972900-1-lgs201920130244@gmail.com Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'include')
0 files changed, 0 insertions, 0 deletions