xen-netfront: handle NULL returned by xdp_convert_buff_to_frame()
authorAlexey Nepomnyashih <sdl@nppct.ru>
Thu, 17 Apr 2025 12:21:17 +0000 (12:21 +0000)
committerJakub Kicinski <kuba@kernel.org>
Tue, 22 Apr 2025 01:56:46 +0000 (18:56 -0700)
commitcc3628dcd851ddd8d418bf0c897024b4621ddc92
tree645e99cb27092818920c1bfb8e1235a34111212f
parent3a7012020532c5a5bb75201a073055f029332299
xen-netfront: handle NULL returned by xdp_convert_buff_to_frame()

The function xdp_convert_buff_to_frame() may return NULL if it fails
to correctly convert the XDP buffer into an XDP frame due to memory
constraints, internal errors, or invalid data. Failing to check for NULL
may lead to a NULL pointer dereference if the result is used later in
processing, potentially causing crashes, data corruption, or undefined
behavior.

On XDP redirect failure, the associated page must be released explicitly
if it was previously retained via get_page(). Failing to do so may result
in a memory leak, as the pages reference count is not decremented.

Cc: stable@vger.kernel.org # v5.9+
Fixes: 6c5aa6fc4def ("xen networking: add basic XDP support for xen-netfront")
Signed-off-by: Alexey Nepomnyashih <sdl@nppct.ru>
Link: https://patch.msgid.link/20250417122118.1009824-1-sdl@nppct.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/xen-netfront.c