Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp947139pxb; Sun, 7 Mar 2021 00:49:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJw8Hom/vJeTDSu1zaZ45OP8J34N7VbZUY5ZlItRwnnEUD7vCJ2fkWafuwK8LuVaopjyJbx+ X-Received: by 2002:a17:906:380c:: with SMTP id v12mr10028167ejc.65.1615106994144; Sun, 07 Mar 2021 00:49:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615106994; cv=none; d=google.com; s=arc-20160816; b=gb3bY4jkE5iBvfeuf2LISHhDTEQkhddtehLc9ReZoP3QXFU12/UpABJrX39PqpvQ+i 2SpqXFcTh6CW12zbhBrtyTWygaEnfC1h+IxwACLY+6k/LCzt2Dy7i8VTWW2EgTM24v4g Obt8V/7E8JVyFbXIvSRyfCnMzAiRCFbzmeRW/9AbWJccK6W41q1VGjyaU3UGJTuIz1tO 9XbSQuFBH8sWEd5OpoYISnYypqRiTF3tMFs3FMwmYu2RkvH3Y+j60YN0lSJdr3Vx93se jdue0CZj2LhGpcHOStvPPF0io8vdx+PrpkDW86qRmhWZVlY+KBAF/ZlNKX8GLhl9Y51f cfXw== 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=5WA49KtxVGIwb3eXl30IXZXGXZZpFGkYnUXeh5u+VtU=; b=s3GY9fQ/GWdi0AD3PslLzNyDyBX5lSLhiThLKXDT5mWY9o7XBDIp4MKNt8/n/f9Nn2 E8BvF85WrnkyhrUJNonLuyWR5FtecdRT+UM+tbjEoSeCwhJDiWs9FgLXVoorNNReCrur Hj7qVtv4oKuLBBoSGG1KSiHkY53M6lARf4bGQzXkJIRXaVqdwOUcG6x3l08PHnHSlz5Q KnFQ3B3yC8FZCx/gqPWqiQ9fhPethSvutwM5Hkh8jvHIKJPoCIsS3dIG8AkwfEB+/pFq jc1jeKMxCvGCIcZLZQt/2qnMS68SBeBU8Yc4rMnQePvJHUneco8XFUrg9RTbvfgafyhn 66Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aWiLJlkj; 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.49.30; Sun, 07 Mar 2021 00:49:54 -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=aWiLJlkj; 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 S230070AbhCGIq3 (ORCPT + 99 others); Sun, 7 Mar 2021 03:46:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40766 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229872AbhCGIqC (ORCPT ); Sun, 7 Mar 2021 03:46:02 -0500 Received: from mail-pg1-x52f.google.com (mail-pg1-x52f.google.com [IPv6:2607:f8b0:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ECB2C06174A; Sun, 7 Mar 2021 00:46:01 -0800 (PST) Received: by mail-pg1-x52f.google.com with SMTP id n9so3442760pgi.7; Sun, 07 Mar 2021 00:46:01 -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=5WA49KtxVGIwb3eXl30IXZXGXZZpFGkYnUXeh5u+VtU=; b=aWiLJlkjxnleVeMFtvMkgAXx2zUKIFqlSjY1TwJg4mO5qbAjrOAvc1czyJClBLuuf3 AeNlgPckkjPMSV9A3qmz34xLL36dCb5bPr+xTDwFzUhcDxWljouT6PvseM21pQSkXg3P OmZrIfbnmfWpUJCRgvqDcIWKvXdEekOHKtApnv6UQYOLqDxgCMaZ9xU8PDNTpvwwuU11 j9FM0CJvFhaGVfm79ECh2j0izT+xTho31HvlWrQ3m2Y2e9AgejRH7fsR06CGvWS5vkHX IphfomPR8aUXX+Du3rx733L0xihAvGdH9Ntdr6UHX+E6K9O+C8VvdqEiDYoSWTxqnvoH X8KQ== 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=5WA49KtxVGIwb3eXl30IXZXGXZZpFGkYnUXeh5u+VtU=; b=D/C7SJCll589w3o9iFkqlnGr8yn+RF91euDde2isCtZrsd6zj992BVrgguNx2e7830 Px8W9coJbvakbGJl1wAR7JmumV6l4GJ0dGh52fxreIJAhRKp1w3FbTdki3ezKhfnqhbK PqFgLLylQCqm7CJqMxrWUCVGcV4Qtvi8kAcEh9VWQ9vmdeDIPSTVTC6TITi1kI5icATG aj5OGtDiKkJRK8yggm2Ck9JYFWXriIkdC3zwwQtnGyfH69j87Kc9MrOvz80QENYANQGE XJwzMags7520rDIRu8jXV3BSn24QXXFAaCJq+hCShk469NXyTdE5X5ZGvtCmVsvSv15P jmKQ== X-Gm-Message-State: AOAM531Ui5QQV32WXi8QYA+aOH/fTLTMjxzFeyGQJ5I2ShfaFJc6p9ma f2Uidpbvg7cLX3lBD3397Os= X-Received: by 2002:a63:580d:: with SMTP id m13mr15877206pgb.342.1615106761161; Sun, 07 Mar 2021 00:46:01 -0800 (PST) Received: from localhost.localdomain ([45.135.186.66]) by smtp.gmail.com with ESMTPSA id h6sm7208395pfb.157.2021.03.07.00.45.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 07 Mar 2021 00:46:00 -0800 (PST) From: Jia-Ju Bai To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] usb: gadget: legacy: fix error return code of multi_bind() Date: Sun, 7 Mar 2021 00:45:45 -0800 Message-Id: <20210307084545.21775-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 multi_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/multi.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/legacy/multi.c b/drivers/usb/gadget/legacy/multi.c index ec9749845660..7734bf77b309 100644 --- a/drivers/usb/gadget/legacy/multi.c +++ b/drivers/usb/gadget/legacy/multi.c @@ -399,8 +399,10 @@ static int __ref multi_bind(struct usb_composite_dev *cdev) struct usb_descriptor_header *usb_desc; usb_desc = usb_otg_descriptor_alloc(gadget); - if (!usb_desc) + if (!usb_desc) { + status = -ENOMEM; goto fail_string_ids; + } usb_otg_descriptor_init(gadget, usb_desc); otg_desc[0] = usb_desc; otg_desc[1] = NULL; -- 2.17.1