mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Michael Riesch <michael.riesch@wolfvision.net>
To: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] of: overlay: improve error handling in of_overlay_apply_tree
Date: Wed, 21 Sep 2022 08:55:12 +0200	[thread overview]
Message-ID: <2ab1b3d8-eff0-f012-94bb-a6ddc61b982f@wolfvision.net> (raw)
In-Reply-To: <20220905100717.150557-2-michael.riesch@wolfvision.net>

Hi all,

On 9/5/22 12:07, Michael Riesch wrote:
> Propagate any error from of_overlay_apply_symbols and let the user
> know if the provided overlay is not applicable.
> 
> Signed-off-by: Michael Riesch <michael.riesch@wolfvision.net>
> ---
>  drivers/of/overlay.c | 14 +++++++++-----
>  1 file changed, 9 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index 20a43f5170..20686db511 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c
> @@ -115,8 +115,8 @@ static char *of_overlay_fix_path(struct device_node *root,
>  	return basprintf("%s%s", target->full_name, path_tail);
>  }
>  
> -static void of_overlay_apply_symbols(struct device_node *root,
> -				     struct device_node *overlay)
> +static int of_overlay_apply_symbols(struct device_node *root,
> +				    struct device_node *overlay)
>  {
>  	const char *old_path;
>  	char *new_path;
> @@ -129,12 +129,12 @@ static void of_overlay_apply_symbols(struct device_node *root,
>  
>  	if (!overlay_symbols) {
>  		pr_debug("overlay doesn't have a __symbols__ node\n");
> -		return;
> +		return -EINVAL;

Come to think of it, do all overlays need to provide a __symbols__ node?
If not, this check is overly strict.

>  	}
>  
>  	if (!root_symbols) {
>  		pr_info("root doesn't have a __symbols__ node\n");
> -		return;
> +		return -EINVAL;

Ditto for the root.

>  	}
>  
>  	list_for_each_entry(prop, &overlay_symbols->properties, list) {
> @@ -148,6 +148,8 @@ static void of_overlay_apply_symbols(struct device_node *root,
>  			 prop->name, new_path);
>  		of_property_write_string(root_symbols, prop->name, new_path);
>  	}
> +
> +	return 0;
>  }
>  
>  static int of_overlay_apply_fragment(struct device_node *root,
> @@ -190,7 +192,9 @@ int of_overlay_apply_tree(struct device_node *root,
>  		goto out_err;
>  
>  	/* Copy symbols from resolved overlay to base device tree */
> -	of_overlay_apply_symbols(root, resolved);
> +	err = of_overlay_apply_symbols(root, resolved);
> +	if (err)
> +		goto out_err;

If both checks need to be relaxed, the complete patch should be reverted
I guess :-/

Thanks in advance for your comments.

Best regards,
Michael

>  
>  	/* Copy nodes and properties from resolved overlay to root */
>  	for_each_child_of_node(resolved, fragment) {



  reply	other threads:[~2022-09-21  6:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-05 10:07 [PATCH 0/2] of: overlay: avoid potential null pointer exception Michael Riesch
2022-09-05 10:07 ` [PATCH 1/2] of: overlay: improve error handling in of_overlay_apply_tree Michael Riesch
2022-09-21  6:55   ` Michael Riesch [this message]
2022-09-21  7:57     ` Michael Tretter
2022-09-21 10:00       ` Michael Riesch
2022-09-05 10:07 ` [PATCH 2/2] of: overlay: avoid potential null pointer exception Michael Riesch
2022-09-12  9:16 ` [PATCH 0/2] " 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=2ab1b3d8-eff0-f012-94bb-a6ddc61b982f@wolfvision.net \
    --to=michael.riesch@wolfvision.net \
    --cc=barebox@lists.infradead.org \
    /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