usb: gadget: g_dnl: Fix NULLPTR dereference when serial# is unset
authorMichael Ferolito <michaelsunn101@gmail.com>
Tue, 28 Jan 2025 03:09:45 +0000 (21:09 -0600)
committerMattijs Korpershoek <mkorpershoek@baylibre.com>
Thu, 6 Feb 2025 08:07:24 +0000 (09:07 +0100)
commitdcf1c627cf436191919c5a3b153d1033245b54b7
tree8057ab8a2e0ceee385b4ed86b69abc802dd1b760
parentb3c09eb36529fbb277bec17b35e638f42cb33683
usb: gadget: g_dnl: Fix NULLPTR dereference when serial# is unset

The current behaviour of this function will dereference a null pointer
if the serial# environment variable is unset. This was discovered on a
board where U-Boot did not have access to the first 256MB of ram,
resulting in a board crash.
In the event that U-Boot has full access to memory, it will still read
from address 0, which is probably not optimal.
This simple check is enough to fix it

Signed-off-by: Michael Ferolito <michaelsunn101@gmail.com>
Cc: Marek Vasut <marex@denx.de>
Cc: Heiko Schocher <hs@denx.de>
Cc: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Link: https://lore.kernel.org/r/20250128030945.1219589-1-michaelsunn101@gmail.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@baylibre.com>
drivers/usb/gadget/g_dnl.c