From: schspa <schspa@gmail.com>
To: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: u-boot@lists.denx.de, Sean Anderson <seanga2@gmail.com>,
Simon Glass <sjg@chromium.org>
Subject: Re: [PATCH] part: return -ENOSYS when get_info not valid.
Date: Wed, 20 Oct 2021 10:37:11 +0800 [thread overview]
Message-ID: <c3d52b2a6ab1db2502bc82295511fe69740f5972.camel@gmail.com> (raw)
In-Reply-To: <8f915095-7fd2-8100-878e-ad9caacd7655@gmx.de>
在 2021-10-19星期二的 17:23 +0200,Heinrich Schuchardt写道:
> On 10/19/21 15:35, zhaohui.shi wrote:
> > From: schspa <schspa@gmail.com>
> >
> > In some case, get_info() interface can be NULL, add this check to
> > stop
> > from crash.
>
> Thank you for reviewing the partition driver code.
>
> There seems to be no driver missing a get_info implementation. Where
> did
> you run into a problem?
>
Yes, I do run into a problem, In my spl build, CONFIG_SPL_FS_EXT4,
CONFIG_SPL_FS_FAT, CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_PARTITION are all
not enabled. In this case, get_info implementation is NULL. see
'part_get_info_ptr' and 'part_print_ptr' and part_efi.c for detail.
> Why should we only check .get_info and not .test and not .print?
>
All part type driver have .test implementation, it can't be NULL,
and .print have NULL pointer judgement already.
> >
> > Signed-off-by: schspa <schspa@gmail.com>
>
> Please, provide a name.
>
> > ---
> > disk/part.c | 7 +++++++
> > 1 file changed, 7 insertions(+)
> >
> > diff --git a/disk/part.c b/disk/part.c
> > index a6a8f7052b..7af3240ec7 100644
> > --- a/disk/part.c
> > +++ b/disk/part.c
> > @@ -668,6 +668,13 @@ int part_get_info_by_name_type(struct blk_desc
> > *dev_desc, const char *name,
> > part_drv = part_driver_lookup_type(dev_desc);
> > if (!part_drv)
> > return -1;
> > +
> > + if (!part_drv->get_info) {
> > + PRINTF("## Driver %s does not have the get_info()
> > method\n",
> > + part_drv->name);
>
> Please, use log_debug() to avoid noise on the console on every boot.
>
I think it's OK to use PRINTF, because of this BUG occurs only when
user give a bad part configuration, and this error message can prompt
the user that a configuration error has occurred.
Besides, 'part_get_info' use PRINTF for this null pointer protection
too.
> Best regards
>
> Heinrich
>
> > + return -ENOSYS;
> > + }
> > +
> > for (i = 1; i < part_drv->max_entries; i++) {
> > ret = part_drv->get_info(dev_desc, i, info);
> > if (ret != 0) {
> >
--
Best regards
schspa <schspa@gmail.com>
next prev parent reply other threads:[~2021-10-20 12:15 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-19 13:35 [PATCH] part: return -ENOSYS when get_info not valid zhaohui.shi
2021-10-19 15:23 ` Heinrich Schuchardt
2021-10-20 2:37 ` schspa [this message]
2021-10-20 4:44 ` Heinrich Schuchardt
2021-10-20 5:54 ` schspa
2021-10-20 6:57 ` Heinrich Schuchardt
-- strict thread matches above, loose matches on Subject: below --
2021-10-19 8:17 schspa
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=c3d52b2a6ab1db2502bc82295511fe69740f5972.camel@gmail.com \
--to=schspa@gmail.com \
--cc=seanga2@gmail.com \
--cc=sjg@chromium.org \
--cc=u-boot@lists.denx.de \
--cc=xypron.glpk@gmx.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