]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
9p/trans_xen: make cleanup idempotent after dataring alloc errors
authorYufan Chen <ericterminal@gmail.com>
Tue, 24 Mar 2026 15:30:22 +0000 (23:30 +0800)
committerDominique Martinet <asmadeus@codewreck.org>
Thu, 16 Apr 2026 02:57:01 +0000 (02:57 +0000)
commit72cb9ee4f6d80962df17c9763b14e62e28fd85a2
treee86afc753616a048a8031492a1d34ac247a58489
parent890d56964c62dfbe228b30b157811088cf64f9f1
9p/trans_xen: make cleanup idempotent after dataring alloc errors

xen_9pfs_front_alloc_dataring() tears down resources on failure but
leaves ring fields stale. If xen_9pfs_front_init() later jumps to the
common error path, xen_9pfs_front_free() may touch the same resources
again, causing duplicate/invalid gnttab_end_foreign_access() calls and
potentially dereferencing a freed intf pointer.

Initialize dataring sentinels before allocation, gate teardown on those
sentinels, and clear ref/intf/data/irq immediately after each release.

This keeps cleanup idempotent for partially initialized rings and
prevents repeated teardown during init failure handling.

Signed-off-by: Yufan Chen <ericterminal@gmail.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Message-ID: <20260324153023.86853-2-ericterminal@gmail.com>
Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
net/9p/trans_xen.c