diff options
author | schspa <schspa@gmail.com> | 2021-10-20 20:15:55 +0800 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2021-11-18 18:20:06 -0500 |
commit | 50f7b2effd4971439e9b66467e4abf6688a124d9 (patch) | |
tree | 93894b13a8d90ec42833cac91286461172c30b7d /disk | |
parent | 0171d056ec8b9be9d90af64adce54c6a5571dd15 (diff) | |
download | u-boot-50f7b2effd4971439e9b66467e4abf6688a124d9.tar.gz u-boot-50f7b2effd4971439e9b66467e4abf6688a124d9.tar.bz2 u-boot-50f7b2effd4971439e9b66467e4abf6688a124d9.zip |
part: return -ENOSYS when get_info not valid.
In some case, get_info() interface can be NULL, add this check to stop
from crash.
Signed-off-by: schspa <schspa@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'disk')
-rw-r--r-- | disk/part.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/disk/part.c b/disk/part.c index a6a8f7052b..fe1ebd4adf 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) { + log_debug("## Driver %s does not have the get_info() method\n", + part_drv->name); + return -ENOSYS; + } + for (i = 1; i < part_drv->max_entries; i++) { ret = part_drv->get_info(dev_desc, i, info); if (ret != 0) { |