]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
usbnet: ipheth: refactor NCM datagram loop
authorFoster Snowhill <forst@pen.gy>
Sat, 25 Jan 2025 23:54:06 +0000 (00:54 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 17 Feb 2025 09:05:16 +0000 (10:05 +0100)
commitcf63d65ab9bb78a50f440ac9e59431e8e66de622
treec0d641940f9b5c78fc63f5ec960271174bd36ee7
parent387ec9277a9e74db5c28b0be74bb3e4db850fb75
usbnet: ipheth: refactor NCM datagram loop

commit 2a9a196429e98fcc64078366c2679bc40aba5466 upstream.

Introduce an rx_error label to reduce repetitions in the header
signature checks.

Store wDatagramIndex and wDatagramLength after endianness conversion to
avoid repeated le16_to_cpu() calls.

Rewrite the loop to return on a null trailing DPE, which is required
by the CDC NCM spec. In case it is missing, fall through to rx_error.

This change does not fix any particular issue. Its purpose is to
simplify a subsequent commit that fixes a potential OoB read by limiting
the maximum amount of processed DPEs.

Cc: stable@vger.kernel.org # 6.5.x
Signed-off-by: Foster Snowhill <forst@pen.gy>
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/usb/ipheth.c