From patchwork Thu Nov 2 08:46:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 117769 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp1988279qgn; Thu, 2 Nov 2017 03:35:27 -0700 (PDT) X-Google-Smtp-Source: ABhQp+QvuvxvnD+8OMBXn/NkEtFB3TorPF5fpQsyl+gdqlEuT3dn5W/ZyywG1EBhLgikYCSYt4s1 X-Received: by 10.80.181.90 with SMTP id z26mr3943208edd.76.1509618927890; Thu, 02 Nov 2017 03:35:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509618927; cv=none; d=google.com; s=arc-20160816; b=CNY2QWJsdcMEpOiBraTxTKafV6gav49UlKEUmCnXIkjsWoHA+BkskgfLRJoClwMXMC in8AgzxDIEwKP0v2BT/5A3INvkkvYpTYcilqUZjDdshM80uHp2PNeD+W8HQf4I2ONdDS puBUKvEp1SEGo/MC4IpU9vTcwNvJYy5aQbvQa6fRHFLHBrexF60zueRzPtWKZ35S00AK FKS06+sQ40W7PFFCsz4NY2CUHat1OwnCNC/kkYBAVyVz6PJVmMtT96OVDcQsuCVvdsYB fGQI8XFEmFke5IjdU6B2CXk1wuOJzrFwD4ZMByDIQy/WQWRJdJRmeVPcPDdROdnfsOmG yL7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:message-id:date:to:from:dmarc-filter :arc-authentication-results; bh=IIWfUQGG/qVq0tEXI99CaBX75gWRs76AukrUz2G8g88=; b=Dw/92Hq2+Ycrq49AlMX2Yi+Ex3xsAJ66FeXC9vhd+o0k7X0ZVuxNWp0oYHz9L2oF4W kgUTAY1JzxePKiAKoyYC4Tx/WzwYsZa+pjMzE3k4Q33/vVL+XnOFoxi8di6PWwa/3rxk TIJ0YBO+AXc97P+YN1D921dZsyUbiTqf5II13o28kOPdjbIJb8CReNR1j/Igxa5/9q0z PR58S2a1hn3HLV7hLkSJ+Cdy0ve9zucK2mFSMry6QzMnsOVbj7Lf7IpxyEFmdl07x70A R9KMH5TD0wXqUafO5QVG+MhkYZV7CiK7H79kHVBAiiPeeTqy9z2TX2ys1Tg8Ndwq3CtL 3VtQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Return-Path: Received: from lists.denx.de (dione.denx.de. [81.169.180.215]) by mx.google.com with ESMTP id i42si3193363ede.137.2017.11.02.03.35.27; Thu, 02 Nov 2017 03:35:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) client-ip=81.169.180.215; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 81.169.180.215 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by lists.denx.de (Postfix, from userid 105) id 5B3C1C21DA0; Thu, 2 Nov 2017 10:35:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id C8A92C21C29; Thu, 2 Nov 2017 10:35:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D3DDEC21C26; Thu, 2 Nov 2017 08:46:45 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by lists.denx.de (Postfix) with ESMTPS id B862FC21C29 for ; Thu, 2 Nov 2017 08:46:42 +0000 (UTC) Received: from localhost.localdomain (unknown [45.56.152.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 52FA2218D2; Thu, 2 Nov 2017 08:46:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52FA2218D2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=shawnguo@kernel.org From: Shawn Guo To: Alexander Graf Date: Thu, 2 Nov 2017 16:46:34 +0800 Message-Id: <1509612394-24359-1-git-send-email-shawnguo@kernel.org> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Thu, 02 Nov 2017 10:35:17 +0000 Cc: Andre Przywara , u-boot@lists.denx.de, Peter Jones , project-aspen-dev@linaro.org Subject: [U-Boot] [PATCH] disk: part_dos: fix part_get_info_extended() function X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Shawn Guo The check in part_get_info_extended() for a successful partition searching misses a condition for extended partition. In case of (ext_part_sector == 0), we should anyway mark the partition as found, even if it's an extended partition, i.e. (is_extended(pt->sys_ind) == 0). Otherwise, the extended partition (type 0x0f) will never be identified, and the following recursive call to part_get_info_extended() will get a wrong 'part_num' and 'which_part' parameter. In the end, all those partitions in extended table will not be identified. Let's add the missing OR condition of (ext_part_sector == 0) for is_extended() check to fix the problem. The issue is discovered by running fastboot flash to an extended partition on eMMC. $ fastboot flash mmcsda5 cache.img target reported max download size of 536870912 bytes sending 'mmcsda5' (18796 KB)... OKAY [ 2.144s] writing 'mmcsda5'... FAILED (remote: cannot find partition) finished. total time: 2.261s Signed-off-by: Shawn Guo --- disk/part_dos.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/disk/part_dos.c b/disk/part_dos.c index 1a36be0446ac..4485eb704852 100644 --- a/disk/part_dos.c +++ b/disk/part_dos.c @@ -210,7 +210,7 @@ static int part_get_info_extended(struct blk_desc *dev_desc, if (((pt->boot_ind & ~0x80) == 0) && (pt->sys_ind != 0) && (part_num == which_part) && - (is_extended(pt->sys_ind) == 0)) { + (ext_part_sector == 0 || is_extended(pt->sys_ind) == 0)) { info->blksz = DOS_PART_DEFAULT_SECTOR; info->start = (lbaint_t)(ext_part_sector + le32_to_int(pt->start4));