From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA031C433F5 for ; Wed, 20 Oct 2021 12:16:13 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3507D61359 for ; Wed, 20 Oct 2021 12:16:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3507D61359 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A28778332B; Wed, 20 Oct 2021 14:16:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="RXl5kdAs"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5E1388319B; Wed, 20 Oct 2021 14:16:09 +0200 (CEST) Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B6C348332B for ; Wed, 20 Oct 2021 14:16:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=schspa@gmail.com Received: by mail-qt1-x831.google.com with SMTP id g17so2765362qtk.8 for ; Wed, 20 Oct 2021 05:16:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tQtxN/GqQipOakfiVjJgjWYF4Lnqt0LrTchUp1bbre4=; b=RXl5kdAsh5D/cvlv+88PdQt/mcwBdxnuGWSiKOvIb+K/08ENXENl/YfKohg+EHUxtl gCVM8+bAjvdUjGGnjj9WmfoQkIUGH9yzZSE8/ixQovA8yVsr5W9+auJoeG15OLkpxQTh BikUh2Rz+RCZ0wgde78ScDxtkIk9028N2EbprpgSH4ENNl/qqt8EiIaMT2QRvcQ7OZjY frLmyh3BJ1HDpFT6iZGm1C5oyO8kkcMpSoCEp96/K+nwrZaHoRHeFANeXwW6TAVcMr4A sq3HroQoOHzACRQgsP7QHlTx11D8rROM5yGnX+HTSDx8U9sdO6heZ80hbcW2y8ql0Z53 oXTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=tQtxN/GqQipOakfiVjJgjWYF4Lnqt0LrTchUp1bbre4=; b=FP9fC3cUsB7sZ7c7p1AZpuy6LzYiQW54qtHZtf7pbrpnCWptKxc/5rNY1sdrPmSZpN GLQFtgiQZowj+ResvOZkm17f39DrIqLp6PUX3og7yK3TsXeHcBSFh64pgi4/qv6PKDhG cg0JlaL+0dby6zi91zafc53u/pDiimrpXZeQ/LGyFZrg2h/Fe6XFy5foIMTjnZoql4wH nGjSPDZjfLAF7NXFQpeIWgb80sJfFyckH/1EmKH8I8YyPBOcY4PTLuzjabVdXXsi22mI Mpv60MeQXG0AdkolA+o1zugwOsEMiwiyCMxe43fF5QtMFurLpa9edOr6Pd/3CZKaGJQo kT+w== X-Gm-Message-State: AOAM533uUzfFweosjImNdVPgyY2hRDLGM2cchOLk1tC+n/xdtGb9BZNg exV20oThoNEwug4LGShnspghz1zJSAs= X-Google-Smtp-Source: ABdhPJyl7azMqummhdKlTBmWe3ybGTiH4rYyqGqjHtfFIpmTL7eZidQs+V8do+NNw+mSBgCAhhpHKw== X-Received: by 2002:ac8:5e4e:: with SMTP id i14mr6338026qtx.129.1634732163348; Wed, 20 Oct 2021 05:16:03 -0700 (PDT) Received: from localhost (ec2-3-142-145-253.us-east-2.compute.amazonaws.com. [3.142.145.253]) by smtp.gmail.com with ESMTPSA id bl37sm945357qkb.39.2021.10.20.05.16.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 05:16:02 -0700 (PDT) From: schspa To: u-boot@lists.denx.de Cc: sjg@chromium.org, seanga2@gmail.com, schspa@gmail.com, xypron.glpk@gmx.de Subject: [PATCH v2] part: return -ENOSYS when get_info not valid. Date: Wed, 20 Oct 2021 20:15:55 +0800 Message-Id: <20211020121555.953640-1-schspa@gmail.com> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean In some case, get_info() interface can be NULL, add this check to stop from crash. Signed-off-by: schspa --- 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