From patchwork Fri Mar 22 15:44:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 10866143 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2804C139A for ; Fri, 22 Mar 2019 15:48:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B5E92A8C0 for ; Fri, 22 Mar 2019 15:48:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F391C2A8C3; Fri, 22 Mar 2019 15:48:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3913D2A8C0 for ; Fri, 22 Mar 2019 15:48:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727603AbfCVPr5 (ORCPT ); Fri, 22 Mar 2019 11:47:57 -0400 Received: from mout.kundenserver.de ([212.227.17.24]:57763 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727473AbfCVPr4 (ORCPT ); Fri, 22 Mar 2019 11:47:56 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue108 [212.227.15.145]) with ESMTPA (Nemesis) id 1MIdaF-1hARKf0n1p-00EbpP; Fri, 22 Mar 2019 16:47:36 +0100 From: Arnd Bergmann To: stable@vger.kernel.org, Felipe Balbi , Greg Kroah-Hartman Cc: Peter Chen , Felipe Balbi , Arnd Bergmann , Benjamin Herrenschmidt , Chunfeng Yun , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [BACKPORT 4.4.y 15/25] usb: gadget: composite: fix dereference after null check coverify warning Date: Fri, 22 Mar 2019 16:44:06 +0100 Message-Id: <20190322154425.3852517-16-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190322154425.3852517-1-arnd@arndb.de> References: <20190322154425.3852517-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:UHzL1C8wGGWp8Z6rjDkjmcHGnCq4ZND0jlzDxvJEFDcI4QzSMpX dsftbYeAGsMIFPD3UOU5TnyF8SXJLoet5YoGqms2eDMcAbOsUXpW4yNA5pRGqiOk0rbsZLX 5D2zbCjflsuGo9WxH+hGNkOkmS9hj+qWw3upfwWO8h/HExl2fLpZWc7ZcXE6JHsQ8uRH4fE OIe92it/gkA8w2+2FL1Rw== X-UI-Out-Filterresults: notjunk:1;V03:K0:v5QA9vpxahI=:qJY+RRUd76611b6rhteEig AsQOUp5bSnEEEzkTdVW9NLcXJ5Cq8jB02RvZYy2O0FEFm60pPUsWk0HP4gHBHTehIW+HMAfBy AFO84IxV+HvBB+ju/QocvQPTE0nboh4Lk226699EBvWpPMO522ULxsZ8q0zcdCgDh+anExwMt +fEk7FN2FKE8FFTvyuyfVLn1HH2xIrm5j0EJUtEq7QVSKCg87HbBzpSB0lBG39gqG3LSlVkc7 VLcf/9POgw3Ee8TmH6QpPHtz2kzEEiwzWOt8ayKALq9+AjQccqS2zZd59jjXmN+KyJ0eVlwdO fMCAPmYmwbp54/xSa9rd4gqTzzPem1W3kVe1zbYso+mutniDwUomwHLYaOiYjAYdj3CSPQQZX FQqAoy4zlNCerzTp0cGrfQ8C6suDk/mumdzBu5Ahzo/FKLcM10+kH1/T9R9FL8KeWjRPmEkYK o/S7V/RCO8izxzeSE84tMkw1couiEVonzKsUsgKY7ajMrHXp/kAoKoxbsaSmblXpLDjuwD7HL mgdj5Gn0hEwp2WHqPHjwLOQXQzyPH/uQH1DC9CjvGZxwWlJb/UyCDUM4y76B7hPEITZLXBKDp j+gx9NHB78d7YbNt/QREUwN+tMhxYw07DUhSeb0wfO4wuqGdb4dZHZE301FjRxPa+a6Sy0/hr oWHRMlHzgGaJuh7/xSWREO4g1vaeZjEXecO9dmDvbnVjLC2bATUujRZ1jK6huBFaJENLIEsw1 R+EO3OqdzB67zjhLnWcsvtenpGK96csHQFvcrg== Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Chen cdev->config is checked for null pointer at above code, so cdev->config might be null, fix it by adding null pointer check. Signed-off-by: Peter Chen Signed-off-by: Felipe Balbi (cherry picked from commit c526c62d565ea5a5bba9433f28756079734f430d) Signed-off-by: Arnd Bergmann --- drivers/usb/gadget/composite.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 58f5fbdb6959..8bf54477f472 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -1819,6 +1819,8 @@ unknown: break; case USB_RECIP_ENDPOINT: + if (!cdev->config) + break; endp = ((w_index & 0x80) >> 3) | (w_index & 0x0f); list_for_each_entry(f, &cdev->config->functions, list) { if (test_bit(endp, f->endpoints))