Re: [PATCH net] net: wwan: mhi_wwan_mbim: fix dangling links on registration failure

From: Paolo Abeni

Date: Tue Nov 17 2026 - 07:18:54 EST


On 11/11/26 12:32, Xia Yan wrote:
mhi_mbim_newlink() adds the link to mbim->link_list before calling
register_netdevice(). If registration fails, the caller frees the
netdev without removing the link, leaving a dangling list entry that
RCU readers such as mhi_mbim_rx() can access after free.

Register the netdev before adding the link to the list so that failed
registrations do not publish a link.

Found while reviewing newlink error paths. A UML/KASAN test module
using driver wrappers and a fake MHI context reproduced the use-after-free
in the driver's RCU lookup. The fix passed the registration-failure and
create/delete tests. Both UML builds passed with W=1.

Fixes: aa730a9905b7 ("net: wwan: Add MHI MBIM network driver")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Xia Yan <yanxia@xxxxxxxxxxxxxxxxxxxx>

This is not 'net' nor stable material.

/P