mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
RDMA/rvt: Return NULL after port allocation failure
rvt_alloc_device() deallocates the IB device when its port array cannot
be allocated but then returns the pointer to the released allocation.
Callers treat any non-NULL value as valid and dereference it, resulting
in a use-after-free.
Return NULL immediately after deallocation so callers can propagate the
allocation failure.
Fixes: ff6acd6951 ("IB/rdmavt: Add device structure allocation")
Link: https://patch.msgid.link/20260708-clean-init-one-hfi1-v1-1-b9e9641268a5@nvidia.com
Reviewed-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
This commit is contained in:
parent
9539e61966
commit
2982eaf3b9
|
|
@ -55,8 +55,10 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
|
|||
return rdi;
|
||||
|
||||
rdi->ports = kzalloc_objs(*rdi->ports, nports);
|
||||
if (!rdi->ports)
|
||||
if (!rdi->ports) {
|
||||
ib_dealloc_device(&rdi->ibdev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return rdi;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user