From patchwork Tue Sep 12 08:57:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick DELAUNAY X-Patchwork-Id: 812738 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3xrzGd62J6z9s81 for ; Tue, 12 Sep 2017 18:58:17 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 85722C21F95; Tue, 12 Sep 2017 08:58:07 +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.7 required=5.0 tests=RCVD_IN_DNSWL_LOW 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 F09A9C21DBA; Tue, 12 Sep 2017 08:58:04 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id B4C01C21DBA; Tue, 12 Sep 2017 08:58:03 +0000 (UTC) Received: from mx07-00178001.pphosted.com (mx08-00178001.pphosted.com [91.207.212.93]) by lists.denx.de (Postfix) with ESMTPS id 698F8C21C40 for ; Tue, 12 Sep 2017 08:58:03 +0000 (UTC) Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v8C8sY2c005408; Tue, 12 Sep 2017 10:58:00 +0200 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2cv76c0dg0-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Tue, 12 Sep 2017 10:58:00 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EE2565C; Tue, 12 Sep 2017 08:57:59 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D537523F4; Tue, 12 Sep 2017 08:57:59 +0000 (GMT) Received: from SAFEX1HUBCAS24.st.com (10.75.90.95) by SAFEX1HUBCAS21.st.com (10.75.90.44) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 12 Sep 2017 10:57:59 +0200 Received: from localhost (10.201.23.85) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.352.0; Tue, 12 Sep 2017 10:57:59 +0200 From: Patrick Delaunay To: Date: Tue, 12 Sep 2017 10:57:56 +0200 Message-ID: <1505206676-13222-1-git-send-email-patrick.delaunay@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [10.201.23.85] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-09-12_04:, , signatures=0 Cc: Stefan Roese , Yann Gautier , Michal Simek Subject: [U-Boot] [PATCH v2] cmd: usb: add check on usb_stor_curr_dev in usb dev command 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" If the command 'usb start' is successfully executed but U-Boot don't found a storage device (usb_stor_curr_dev stay to -1) the next command 'usb dev' without parameter leads to data abort after the message "USB device -1" The added check on usb_stor_curr_dev avoid the issue. Signed-off-by: Patrick Delaunay --- Changes in v2: - Updated the commit message - use command_ret_t for result cmd/usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/usb.c b/cmd/usb.c index 992d414..53305bb 100644 --- a/cmd/usb.c +++ b/cmd/usb.c @@ -806,6 +806,10 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) printf("... is now current device\n"); return 0; } else { + if (usb_stor_curr_dev < 0) { + printf("no current device selected\n"); + return CMD_RET_FAILURE; + } printf("\nUSB device %d: ", usb_stor_curr_dev); stor_dev = blk_get_devnum_by_type(IF_TYPE_USB, usb_stor_curr_dev);