Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp361001pxb; Thu, 12 Nov 2020 05:51:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6JcpLNlB++jisc6ggtAqz4aEKnoO7N3ks+ckAPGlBe8qnX+9nroH2Yn4UoOCNAeIQfT1P X-Received: by 2002:a17:906:6409:: with SMTP id d9mr30019134ejm.344.1605189111737; Thu, 12 Nov 2020 05:51:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605189111; cv=none; d=google.com; s=arc-20160816; b=hChwTzmINbwJ0OOqvbaiKOYqjQH95GPujLeEXc68QKrrkkXMQGpJJEExlHzehDGdQs z/rQxut8p2E1nv90oOzzZRKT0UjoX5BCHXQFZ+TlzJxYyy0pcPX7aJNLq4K6uCiZB9oA kvN7yFZ7xXYrsiSxf5toU/xBUscKyBI0wLlWNCsKJXtSsq3vCwMiZiJB8QEb8LxV6yoc EjOv+Z36wON706FkczuHxlNBGMGWPLHyBFFmX2xJBI0Vejq+hpPL5cQiUVFTD3zCOqcJ wzusHWp7EM3SnNuGkl4CNGneeWqo3100jZyi+lO0HW/yGTnnJCw43J/PurkUsEEkVmSf +GFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=8C8DDyS6t1egAa9t1AKvjK9fy4X5K0PqQTyHA8MwZyM=; b=LVxBNLDdBfpJLa3anSrDlDwSoq9nfGKFfMLBhRfB8J89/DL+D4ijTFu0R5FSUeegsj yIvKPBMGo1JZ8p2R7OHUoXnOAyST82nCIgQbbyCvAdgXU6sadZNjRgrIRz1+Q36KX1/B dQoUOY+RQI8NbHJB99gpXv1QKKJ42BeQcJgItbf1lHVXYHoftnvmwbkt/CSPPpiEE05J oJdUY9ehB53GSbc43oJd5qptYEeSB8MgZBN0SL+7MTywkFlrxxXUS/HFxSeq0r9Yi9wh sxFfC780jeGbo8IXwuhgJvXh7ydtR+qq99WmPMpk4NqVxYpQxsRGHIt5DkwjasnJLZFq q5rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j13si3497523ejy.399.2020.11.12.05.51.29; Thu, 12 Nov 2020 05:51:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728405AbgKLNth (ORCPT + 99 others); Thu, 12 Nov 2020 08:49:37 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7220 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727790AbgKLNtg (ORCPT ); Thu, 12 Nov 2020 08:49:36 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CX2yQ5rqHzkhhY; Thu, 12 Nov 2020 21:49:18 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.487.0; Thu, 12 Nov 2020 21:49:23 +0800 From: Chen Zhou To: CC: , , , , , , , Hulk Robot Subject: [PATCH v2] usb: gadget: mass_storage: fix error return code in msg_bind() Date: Thu, 12 Nov 2020 21:54:23 +0800 Message-ID: <20201112135423.89536-1-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix to return a negative error code from the error handling case instead of 0 in function msg_bind(), as done elsewhere in this function. Fixes: d86788979761 ("usb: gadget: mass_storage: allocate and init otg descriptor by otg capabilities") Reported-by: Hulk Robot Signed-off-by: Chen Zhou --- drivers/usb/gadget/legacy/mass_storage.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/legacy/mass_storage.c b/drivers/usb/gadget/legacy/mass_storage.c index 9ed22c5fb7fe..ac1741126619 100644 --- a/drivers/usb/gadget/legacy/mass_storage.c +++ b/drivers/usb/gadget/legacy/mass_storage.c @@ -175,8 +175,10 @@ static int msg_bind(struct usb_composite_dev *cdev) struct usb_descriptor_header *usb_desc; usb_desc = usb_otg_descriptor_alloc(cdev->gadget); - if (!usb_desc) + if (!usb_desc) { + status = -ENOMEM; goto fail_string_ids; + } usb_otg_descriptor_init(cdev->gadget, usb_desc); otg_desc[0] = usb_desc; otg_desc[1] = NULL; -- 2.20.1