mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] tlv: register_device() error handling
@ 2025-12-01 14:12 Jonas Rebmann
  2025-12-01 14:20 ` Ahmad Fatoum
  2025-12-02  6:52 ` Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Jonas Rebmann @ 2025-12-01 14:12 UTC (permalink / raw)
  To: Sascha Hauer, BAREBOX; +Cc: Jonas Rebmann

register_device() returns 0 on success, or an error, which must be
handled appropriately.

Signed-off-by: Jonas Rebmann <jre@pengutronix.de>
---
Resolves coverity CID 584716 (Unchecked return value).
---
 common/tlv/bus.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/common/tlv/bus.c b/common/tlv/bus.c
index a59f8d297a..36a3022fdf 100644
--- a/common/tlv/bus.c
+++ b/common/tlv/bus.c
@@ -23,6 +23,7 @@ struct tlv_device *tlv_register_device(struct tlv_header *header,
 	const char *name = NULL;
 	struct device *dev;
 	static int id = 0;
+	int ret;
 
 	tlvdev = xzalloc(sizeof(*tlvdev));
 
@@ -46,7 +47,12 @@ struct tlv_device *tlv_register_device(struct tlv_header *header,
 
 	dev->device_node = of_new_node(tlv_parent_node, dev_name(dev));
 	dev->device_node->dev = dev;
-	register_device(dev);
+	ret = register_device(dev);
+	if (ret) {
+		pr_err("Failed to register device %s, %d\n", name, ret);
+		free(tlvdev);
+		return ERR_PTR(ret);
+	}
 
 	return tlvdev;
 }

---
base-commit: ec00fef65d808f8bc9c5655262b0e4f8ce2c4e92
change-id: 20251201-tlv-hardening-fd07381bc3f8

Best regards,
--  
Jonas Rebmann <jre@pengutronix.de>




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-12-02  6:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-12-01 14:12 [PATCH] tlv: register_device() error handling Jonas Rebmann
2025-12-01 14:20 ` Ahmad Fatoum
2025-12-02  6:52 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox