public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Quentin Schulz <quentin.schulz@cherry.de>
To: Rasmus Villemoes <ravi@prevas.dk>, u-boot@lists.denx.de
Cc: Tom Rini <trini@konsulko.com>
Subject: Re: [PATCH v2 1/2] disk/part.c: ensure strings in struct disk_partition are valid after successful get_info
Date: Mon, 3 Nov 2025 15:07:27 +0100	[thread overview]
Message-ID: <49fbca7f-35b7-464a-99f8-ae479bc39129@cherry.de> (raw)
In-Reply-To: <20251020121100.1742812-2-ravi@prevas.dk>

Hi Rasmus,

On 10/20/25 2:10 PM, Rasmus Villemoes wrote:
> Not all ->get_info implementations necessarily populate all the string
> members of struct disk_partition.
> 
> Currently, only part_get_info_by_type() (and thereby part_get_info)
> ensure that the uuid strings are initialized; part_get_info_by_type()
> and part_get_info_by_uuid() do not. In fact, the latter could lead to
> a false positive match - if the ->get_info backend does not populate
> info->uuid, stale contents in info could cause the strncasecmp() to
> succeed.
> 
> None of the functions currently ensure that the ->name and ->type
> strings are initialized.
> 
> Instead of forcing all callers of any of these functions to
> pre-initialize info, or all implementations of the ->get_info method
> to ensure there are valid C strings in all four fields, create a small
> helper function and factor all invocations of ->get_info through that.
> 

Considering we only have code calling get_info() function of the part 
driver in the two files changed in this commit, but there's nothing 
forbidding users to call it from their driver or board files, but I 
guess this is good enough and we can worry about non-existing users later?

> This also consolidates the -ENOSYS check and standardizes on using
> log_debug() for reporting absence, instead of the current mix of
> PRINTF and log_debug(). It does mean we have to special-case -ENOSYS
> in the error cases inside the loops in the _by_uuid() and _by_name()
> functions, but it's still a net win in #LOC.
> 

Acked-by: Quentin Schulz <quentin.schulz@cherry.de>

Thanks!
Quentin

  reply	other threads:[~2025-11-03 14:07 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20 12:10 [PATCH v2 0/2] 'part name' subcommand and some robustification Rasmus Villemoes
2025-10-20 12:10 ` [PATCH v2 1/2] disk/part.c: ensure strings in struct disk_partition are valid after successful get_info Rasmus Villemoes
2025-11-03 14:07   ` Quentin Schulz [this message]
2025-10-20 12:11 ` [PATCH v2 2/2] cmd/part.c: implement "part name" subcommand Rasmus Villemoes
2025-11-03 14:14   ` Quentin Schulz
2025-11-03 20:38     ` Rasmus Villemoes
2025-11-04  9:36       ` Quentin Schulz
2025-11-07 20:19 ` [PATCH v2 0/2] 'part name' subcommand and some robustification Tom Rini
2025-11-08  0:02   ` Rasmus Villemoes
2025-11-08 15:01     ` Tom Rini
2025-11-10  0:33       ` Rasmus Villemoes

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=49fbca7f-35b7-464a-99f8-ae479bc39129@cherry.de \
    --to=quentin.schulz@cherry.de \
    --cc=ravi@prevas.dk \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.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