Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp949505pxb; Sun, 7 Mar 2021 00:56:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJx0wtAaTg91TBViD92fXiq3k1Gfx/Pr5OAPcBGGIL03L8yIAONSfKT0Ng+3Vw4L+7nGu7Q/ X-Received: by 2002:a17:906:c081:: with SMTP id f1mr10107355ejz.97.1615107379740; Sun, 07 Mar 2021 00:56:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615107379; cv=none; d=google.com; s=arc-20160816; b=FoBGlqOg1TEev6ak6GkxMYvleakGvJcfBGhuAmXWWujIyqkvic2CiJYGJCMSrWnllL NM9VLgTol/zq2Bff2xEdTjiVVJDJibkNKag4+Ve8NVjWr8iY/jyIMRXJ1n986Rz7TNfl HybKNaNZwEl1kAl94/qQKqakMSEPum2QSlD82Ft1BlIBrC3+9RauFZoZr0tFNwVM8575 3vyJkbjSNHviYuk1RbwM3s3tDRdh6iokpna+2LqjS/NBshMdMdgRV03BakZSopvrALvs n0H1dVS8jmNM9NupD5sJOwuRb+6AMWhMoGcMH1pFS5ODV7JvE9x1ajMyypvv624CPHT2 7trA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=xYRfDyZoEfXhEjhI6xDP/cz7T5RB9Ng0myyQQDRDBto=; b=rkR1/IzuJUYk2xLvtgx9kKKLEUyC8FytmbwGkzWWNcmKJ7wG71z6e5vny81bxw6K2G wS1gpnN0tjYzN9k50czxdqdI9Y8WpvIB9xy76qUUXuV5qHkkoWGS2lYFExS90lK2DgvZ B8SwVzRhP5w5Ps0rHIH2OOMPQZtVUlxjsrzF2oB/C1FVSnV/xWiZGqmJsQVHkbESLmBa jKKOXUxWTOdbth2AaD56yUgUW1F2TjZkfx47mgoHDplzyz3xe3NeWAL13R9kQaGTdOpc yxafW8EX8bhiBWNxrFXIvBqLOc+lQpV6C6fVxq4x5JIr2U0GGmNc3xVtqy5IWhZmxp/p BNrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=luGxvim7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a10si5491598edf.499.2021.03.07.00.55.56; Sun, 07 Mar 2021 00:56:19 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=luGxvim7; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230247AbhCGIxD (ORCPT + 99 others); Sun, 7 Mar 2021 03:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230045AbhCGIwa (ORCPT ); Sun, 7 Mar 2021 03:52:30 -0500 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97F79C06174A; Sun, 7 Mar 2021 00:52:30 -0800 (PST) Received: by mail-pf1-x42b.google.com with SMTP id l7so5237772pfd.3; Sun, 07 Mar 2021 00:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=xYRfDyZoEfXhEjhI6xDP/cz7T5RB9Ng0myyQQDRDBto=; b=luGxvim7HU3mrB0ywo9ZVV5HO+UXuujus9gH+kFM6Exw/oRbZx/Zk7VrDSHoZv9Cwr igr9Iyd3oEMDXAb+I6KiHsRx2ZkVVeK7sJY4+E1VoHg9GeFzX9O5Gj/mHu/js/fW0b97 AShiWlkeoTeM4FepE/QeCBvaSu4P+T6nBQR1Zz4Up6q2ZOEzxKNh+VlW72NFz0NWEDf0 qpbyDyc9sl40fk9V692uXJHRO9cMQ1rzn9YIOIrOTXfCgcKdR5P3PvDfwP42prSwXk7M MmI220ulX3Jv5oG8jWQPg9t4oXOv2qXaANkf2blKyhxVVPvKjXnzh4ZQxc5R2sOk0zJ8 PTpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=xYRfDyZoEfXhEjhI6xDP/cz7T5RB9Ng0myyQQDRDBto=; b=SWDPksjL+o9eDQG/nSdRv4Is1vMQkDJ/bV0YIdTjfJqpN/bajX6TD1Zbyrj2d0Knts DLEd7t+Vk/6YvnaYJkY/0EdD5R4bWJa+eulhgPXKHZgOq6cw19HQ3M/ptmvfb0Clkd3a jbv0YW8kFStKqsYABj+iDD/Ai7PLilpzdnHvjHj5muiYobIDanQ5b/2Arl3T+HmZQuhU EqFzRsdh78cLxeP/QIg6lGgKpWt1bSFUtgQXDEsZMGO5Xi2jxFz8SV+bhamX44BJvu2L AZ5tIf3UJ5/bdHrFvXN4RX5q8whvauRLYgBzc4UWcbGSMoP9ONJIjTd9imiRHbpzOhcP lYLw== X-Gm-Message-State: AOAM533nLHKuwM2DxxsTTyfhVyuU8jzSBlGk2tbmPn5f9UVJf+97Ufd3 By2LIP2KkdRazJWc4K/kGJTi4cE7vM81hg14 X-Received: by 2002:a63:2009:: with SMTP id g9mr15931070pgg.219.1615107150198; Sun, 07 Mar 2021 00:52:30 -0800 (PST) Received: from localhost.localdomain ([45.135.186.66]) by smtp.gmail.com with ESMTPSA id h3sm6517268pgm.67.2021.03.07.00.52.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Mar 2021 00:52:29 -0800 (PST) From: Jia-Ju Bai To: balbi@kernel.org, gregkh@linuxfoundation.org, weiyongjun1@huawei.com Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH resend] usb: gadget: legacy: fix error return code of msg_bind() Date: Sun, 7 Mar 2021 00:52:19 -0800 Message-Id: <20210307085219.22147-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When usb_otg_descriptor_alloc() returns NULL to usb_desc, no error return code of msg_bind() is assigned. To fix this bug, status is assigned with -ENOMEM in this case. Reported-by: TOTE Robot > Signed-off-by: Jia-Ju Bai --- 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.17.1