From: Jonas Rebmann <jre@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>,
BAREBOX <barebox@lists.infradead.org>
Cc: Jonas Rebmann <jre@pengutronix.de>
Subject: [PATCH] tlv: register_device() error handling
Date: Mon, 01 Dec 2025 15:12:43 +0100 [thread overview]
Message-ID: <20251201-tlv-hardening-v1-1-5dcaa5f7aed5@pengutronix.de> (raw)
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>
next reply other threads:[~2025-12-01 14:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-01 14:12 Jonas Rebmann [this message]
2025-12-01 14:20 ` Ahmad Fatoum
2025-12-02 6:52 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251201-tlv-hardening-v1-1-5dcaa5f7aed5@pengutronix.de \
--to=jre@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=s.hauer@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox