Skip to content
Commit 61faa6dd authored by Mattijs Korpershoek's avatar Mattijs Korpershoek
Browse files

cmd: bcb: Fix segfault on invalid block device

When blk_get_dev() fails, block NULL and gets de-referenced in
the error path by a printf(), resulting in a crash.

This can be reproduced on sandbox with:

$ ./u-boot --command "bcb load mmc 0 0"

Fix the message by using the functions arguments (iface, devnum)
instead.

Note: partition (being a global static initialized) can be used safely.

This issue has been reported by coverity [1]

[1] https://lore.kernel.org/all/20240723141844.GF989285@bill-the-cat/



Fixes: dfeb4f0d ("cmd: bcb: extend BCB C API to allow read/write the fields")
Reviewed-by: default avatarDmitrii Merkurev <dimorinny@google.com>
Link: https://lore.kernel.org/r/20240724-bcb-crash-v1-1-44caff15bce4@baylibre.com


Signed-off-by: default avatarMattijs Korpershoek <mkorpershoek@baylibre.com>
parent 0b06e052
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment