Re: [PATCH net-next v2 2/2] devlink: sb: do not dereference a missing shared buffer

From
Ivan Vecera <ivecera@redhat.com>
Date
2026-11-02 14:17:26
Reply to
Linkui Xiao, 2026-11-02
On 11/2/26 14:15, Linkui Xiao wrote:
From: Linkui Xiao <redacted>

devl_sb_unregister() looks the shared buffer up by index and only warns
when it is not on the list. list_del() and kfree() are then called on the
NULL result, so unregistering an index that was never registered, or
unregistering the same index twice, turns the warning into a NULL pointer
dereference. list is the first member of struct devlink_sb, so list_del()
reads the next and prev pointers from address 0 before storing to them.

The register side already fails gracefully: devl_sb_register() returns
-EEXIST when the index is taken. Make the unregister side symmetric and
return after the warning.

Fixes: bf7974710a40 ("devlink: add shared buffer configuration")
Signed-off-by: Linkui Xiao <redacted>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://lore.kernel.org/r/20261030033332.3685172-3-xiaolinkui@126.com (local)
---
v2: reposted against net-next at Simon's suggestion; no code change.
Reviewed-by: Ivan Vecera <ivecera@redhat.com>
Thread (7 messages) 7 messages, 4 authors, last reply 9d ago
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help