[PATCH 06/15] commands: tlv: Error out on invalid TLVs
Jonas Rebmann
jre at pengutronix.de
Tue Oct 14 04:02:57 PDT 2025
TLV parsing happens in the TLV drivers probe function
(tlv_probe_from_magic()) but register_device() does not propagate
errors from match(), always returning zero.
match() however ensures that dev->driver is always NULL if an error
occurred on probe and since we're only probing the TLV driver, rely on
that as indicator of an error during TLV parsing (e.g. CRC mismatch).
Signed-off-by: Jonas Rebmann <jre at pengutronix.de>
---
commands/tlv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/commands/tlv.c b/commands/tlv.c
index 6118a2947f..c01a7b0399 100644
--- a/commands/tlv.c
+++ b/commands/tlv.c
@@ -29,7 +29,7 @@ static int do_tlv(int argc, char *argv[])
return COMMAND_ERROR_USAGE;
tlvdev = tlv_register_device_by_path(filename, NULL);
- if (IS_ERR(tlvdev)) {
+ if (IS_ERR(tlvdev) || tlvdev->dev.driver == NULL) {
printf("Could not open \"%s\": %m\n", filename);
return COMMAND_ERROR;
}
--
2.51.0.297.gca2559c1d6
More information about the barebox
mailing list