public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH v2] part: return -ENOSYS when get_info not valid.
@ 2021-10-20 12:15 schspa
  2021-10-24 19:53 ` Simon Glass
  2021-11-18 23:26 ` Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: schspa @ 2021-10-20 12:15 UTC (permalink / raw)
  To: u-boot; +Cc: sjg, seanga2, schspa, xypron.glpk

In some case, get_info() interface can be NULL, add this check to stop
from crash.

Signed-off-by: schspa <schspa@gmail.com>
---
 disk/part.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/disk/part.c b/disk/part.c
index a6a8f7052b..f9b9b89861 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.33.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] part: return -ENOSYS when get_info not valid.
  2021-10-20 12:15 [PATCH v2] part: return -ENOSYS when get_info not valid schspa
@ 2021-10-24 19:53 ` Simon Glass
  2021-11-18 23:26 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2021-10-24 19:53 UTC (permalink / raw)
  To: schspa; +Cc: U-Boot Mailing List, Sean Anderson, Heinrich Schuchardt

On Wed, 20 Oct 2021 at 06:16, schspa <schspa@gmail.com> wrote:
>
> In some case, get_info() interface can be NULL, add this check to stop
> from crash.
>
> Signed-off-by: schspa <schspa@gmail.com>
> ---
>  disk/part.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>

Reviewed-by: Simon Glass <sjg@chromium.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] part: return -ENOSYS when get_info not valid.
  2021-10-20 12:15 [PATCH v2] part: return -ENOSYS when get_info not valid schspa
  2021-10-24 19:53 ` Simon Glass
@ 2021-11-18 23:26 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2021-11-18 23:26 UTC (permalink / raw)
  To: schspa; +Cc: u-boot, sjg, seanga2, xypron.glpk

[-- Attachment #1: Type: text/plain, Size: 292 bytes --]

On Wed, Oct 20, 2021 at 08:15:55PM +0800, schspa wrote:

> 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>

Applied to u-boot/master, thanks!

-- 
Tom

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-18 23:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-20 12:15 [PATCH v2] part: return -ENOSYS when get_info not valid schspa
2021-10-24 19:53 ` Simon Glass
2021-11-18 23:26 ` Tom Rini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox