Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp799690img; Fri, 22 Mar 2019 08:49:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl+kWctEJb0Xd21u5Rdtq7ZGV5J+ykcRereos4nLID3UceQ3HPeZunyoHWwSB03a/1GPdD X-Received: by 2002:a63:8548:: with SMTP id u69mr9516234pgd.85.1553269773303; Fri, 22 Mar 2019 08:49:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553269773; cv=none; d=google.com; s=arc-20160816; b=uTXw8HR8yojKnVDG7Gi0bIlWHFsTbXa0Fxhxr05k24NOWsLDn06jd/q4QBJFsbvZMe xcVXj+EvM4+1+VWNq5mgudrdQiyc7He0BDCsYeyME29b7yl/F8RjrbnlXOqtVVPWsn+W LiZv9B5AJeqrPArFdQXsA340nB+cRyntrx0Lu+q/bVeUYje5Ku2oC74+XE1+28kjbx1Y NNwiMG8fT1Am6+woiirJXJz0PJSb/J16NKaFigmEtlEsS+M92YFeNRHTrYvQImlbdoSE KAdXaNTN2Bs77ICIdPXeaIW0mlsu4Pio0Wp6o0IcFf6pBlgNx0FAi5RxUnv7hdQAIZni 2zZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Ioy9Q/oc6H0hEeQFC/lhOQXJnjsI7vMtB5m/9GAoov4=; b=0a8NMJMMROn2xuACKKbJmoF2+UoXGYCRgKhEoDobeRqvoBuktLE2MI/558M0sCtplE pLIIKbrrVKYlJYpt2KcV79Ij8h2E/5M/osAg+HOIra9ye2YkjvCcQDqczENP9ruXzHWJ ICQOq4Y/RKQ9MGFlr+YFW6+1HYcHXGuC30E1m7SfW+5lo4PEDMHtb5Q+08uFxW8dAR3j HKc3BFo3GOQ/o0go1rchrr1VQ0ScoWx6Bg3GgsqoEKbOKnl2SYhAUS4bDhntOYn6qYIG jDRLzuTxoSG6BHBsrHO+1Nl7J1xPfITehWkFqHaUJz8gvQlo3ey6eydIHaII+ErS5+vX FWQA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m2si7003124pfi.269.2019.03.22.08.49.14; Fri, 22 Mar 2019 08:49:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728188AbfCVPr5 (ORCPT + 99 others); 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 Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:UHzL1C8wGGWp8Z6rjDkjmcHGnCq4ZND0jlzDxvJEFDcI4QzSMpX dsftbYeAGsMIFPD3UOU5TnyF8SXJLoet5YoGqms2eDMcAbOsUXpW4yNA5pRGqiOk0rbsZLX 5D2zbCjflsuGo9WxH+hGNkOkmS9hj+qWw3upfwWO8h/HExl2fLpZWc7ZcXE6JHsQ8uRH4fE OIe92it/gkA8w2+2FL1Rw== X-Spam-Flag: NO 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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)) -- 2.20.0