From patchwork Tue Aug 9 21:36:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Brian Norris X-Patchwork-Id: 109287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id EDA6DB6F76 for ; Wed, 10 Aug 2011 07:37:48 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QqtzK-0006pY-V1; Tue, 09 Aug 2011 21:37:27 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QqtzK-0001c3-EJ; Tue, 09 Aug 2011 21:37:26 +0000 Received: from mms1.broadcom.com ([216.31.210.17]) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QqtzE-0001aD-4b for linux-mtd@lists.infradead.org; Tue, 09 Aug 2011 21:37:21 +0000 Received: from [10.9.200.131] by mms1.broadcom.com with ESMTP (Broadcom SMTP Relay (Email Firewall v6.3.2)); Tue, 09 Aug 2011 14:42:51 -0700 X-Server-Uuid: 02CED230-5797-4B57-9875-D5D2FEE4708A Received: from mail-irva-13.broadcom.com (10.11.16.103) by IRVEXCHHUB01.corp.ad.broadcom.com (10.9.200.131) with Microsoft SMTP Server id 8.2.247.2; Tue, 9 Aug 2011 14:37:05 -0700 Received: from localhost.localdomain (ld-irv-0074 [10.12.160.50]) by mail-irva-13.broadcom.com (Postfix) with ESMTP id 45B3474D03; Tue, 9 Aug 2011 14:37:05 -0700 (PDT) From: "Brian Norris" To: "Artem Bityutskiy" Subject: [PATCH v2 1/5] mtdinfo: don't open NULL pointer when getting region_info with `-a' Date: Tue, 9 Aug 2011 14:36:42 -0700 Message-ID: <1312925806-15929-2-git-send-email-computersforpeace@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1312925806-15929-1-git-send-email-computersforpeace@gmail.com> References: <1312925806-15929-1-git-send-email-computersforpeace@gmail.com> MIME-Version: 1.0 X-WSS-ID: 625F76513DK9479851-01-01 X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110809_173720_454143_4517F75C X-CRM114-Status: GOOD ( 18.44 ) X-Spam-Score: 1.2 (+) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (computersforpeace[at]gmail.com) 0.0 DKIM_ADSP_CUSTOM_MED No valid author signature, adsp_override is CUSTOM_MED 1.2 NML_ADSP_CUSTOM_MED ADSP custom_med hit, and not from a mailing list Cc: brian.foster@maxim-ic.com, Mike Frysinger , Brian Norris , linux-mtd@lists.infradead.org, Mike Frysinger X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This "fixes" a regression found in: commit 266061ebd5d72391f0a0e831b018e8fc7fea68a1 mtdinfo: add regioninfo/eraseblock map display On certain flash (NOR flash that have eraseblock region info), `mtdinfo -a' tries to open the MTD node file, for use with the ioctl MEMGETREGIONINFO; however, we didn't supply a device node path to `mtdinfo -a', so it's using NULL, resulting in errors like: mtdinfo: error!: couldn't open MTD dev: (null) error 14 (Bad address) For now, we can just skip dumping region_info with the `-a' flag. If we find a better way to do this (e.g., export via sysfs, find device nodes via automatic routines, etc.), then we can kill the workaround and this FIXME should be removed. The regression was first reported at: http://lists.infradead.org/pipermail/linux-mtd/2011-July/037232.html The result of recent changes is that we cannot get region_info for devices via the `--all' option. We add a note in the help message warning that mtdinfo may find more info when given a device patch, e.g., /dev/mtdX. Reported-by: Brian Foster CC: Mike Frysinger Signed-off-by: Brian Norris Acked-by: Mike Frysinger --- ubi-utils/mtdinfo.c | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ubi-utils/mtdinfo.c b/ubi-utils/mtdinfo.c index e72d69e..b4a2f4c 100644 --- a/ubi-utils/mtdinfo.c +++ b/ubi-utils/mtdinfo.c @@ -58,6 +58,8 @@ static const char optionsstr[] = " on this MTD device\n" "-M, --map print eraseblock map\n" "-a, --all print information about all MTD devices\n" +" Note: `--all' may give less info per device\n" +" than, e.g., `mtdinfo /dev/mtdX'\n" "-h, --help print help message\n" "-V, --version print program version"; @@ -239,8 +241,14 @@ static void print_region_info(const struct mtd_dev_info *mtd) region_info_t reginfo; int r, fd; - /* If we don't have any region info, just return */ - if (!args.map && mtd->region_cnt == 0) + /* + * If we don't have any region info, just return + * + * FIXME: We can't get region_info (via ioctl) without having the MTD + * node path. This is a problem for `mtdinfo -a', for example, + * since it doesn't provide any filepath information. + */ + if (!args.node || (!args.map && mtd->region_cnt == 0)) return; /* First open the device so we can query it */