From 50f7b2effd4971439e9b66467e4abf6688a124d9 Mon Sep 17 00:00:00 2001 From: schspa Date: Wed, 20 Oct 2021 20:15:55 +0800 Subject: [PATCH] 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 Reviewed-by: Simon Glass --- disk/part.c | 7 +++++++ 1 file changed, 7 insertions(+) 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) { -- 2.39.5