mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Jonas Rebmann <jre@pengutronix.de>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	BAREBOX <barebox@lists.infradead.org>
Subject: Re: [PATCH] tlv: register_device() error handling
Date: Mon, 1 Dec 2025 15:20:32 +0100	[thread overview]
Message-ID: <7e69d888-7891-44b5-9240-e4e65c5242ed@pengutronix.de> (raw)
In-Reply-To: <20251201-tlv-hardening-v1-1-5dcaa5f7aed5@pengutronix.de>

Hi,

On 12/1/25 3:12 PM, Jonas Rebmann wrote:
> 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);

Please drop the error message, there is a single failure mode anyway and
-EINVAL is descriptive enough.

> +		free(tlvdev);
> +		return ERR_PTR(ret);
> +	}
>  
>  	return tlvdev;
>  }
> 
> ---
> base-commit: ec00fef65d808f8bc9c5655262b0e4f8ce2c4e92
> change-id: 20251201-tlv-hardening-fd07381bc3f8
> 
> Best regards,
> --  
> Jonas Rebmann <jre@pengutronix.de>
> 
> 
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2025-12-01 14:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-01 14:12 Jonas Rebmann
2025-12-01 14:20 ` Ahmad Fatoum [this message]
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=7e69d888-7891-44b5-9240-e4e65c5242ed@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=jre@pengutronix.de \
    --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