From patchwork Wed Nov 27 21:45:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thinh Nguyen X-Patchwork-Id: 11264981 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A63AE13B6 for ; Wed, 27 Nov 2019 21:45:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 85A1A215E5 for ; Wed, 27 Nov 2019 21:45:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=synopsys.com header.i=@synopsys.com header.b="QuDHZYdX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727722AbfK0VpS (ORCPT ); Wed, 27 Nov 2019 16:45:18 -0500 Received: from dc8-smtprelay2.synopsys.com ([198.182.47.102]:34670 "EHLO smtprelay-out1.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727963AbfK0VpS (ORCPT ); Wed, 27 Nov 2019 16:45:18 -0500 Received: from mailhost.synopsys.com (sv2-mailhost2.synopsys.com [10.205.2.134]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by smtprelay-out1.synopsys.com (Postfix) with ESMTPS id E493AC0382; Wed, 27 Nov 2019 21:45:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1574891117; bh=6Hfao375F+NO+iwnFV8Dj3+NEuvO6/Yjg572T9OTy0M=; h=Date:From:Subject:To:Cc:From; b=QuDHZYdXO70yU3Lv81gOlGCOS6Aqja7Wq1Ez99Idu8cdj8U1xz1HM61O3XoORUu9z WE0wKP6czUy4AxgF4cg+UW2cWGyP6H5hGwnYy9WuyLioWmpaqTnQdZjSDzGb/41KYM hfSb6Z2CNOtJLDFp2bzx7RgFLfNabEaA080cwQ5GM5VL4PuZOelokDVSDRKBeDrZnY VACaSrLI9nuUqE3DM2w4ym8i1jbBmLJEx5OaqBsBGzAaVuvpEmH4Ycc/Qc/NcmufJw sCD8SKLcJ6laYu51JLdU3q8q7kHU2DkjeAOUmqTJswUgltrmP2/02B2TgmS6FCxeNh cuesFZFYB198Q== Received: from te-lab16 (nanobot.internal.synopsys.com [10.10.186.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mailhost.synopsys.com (Postfix) with ESMTPSA id 8F042A007B; Wed, 27 Nov 2019 21:45:16 +0000 (UTC) Received: by te-lab16 (sSMTP sendmail emulation); Wed, 27 Nov 2019 13:45:15 -0800 Date: Wed, 27 Nov 2019 13:45:15 -0800 Message-Id: From: Thinh Nguyen Subject: [PATCH] usb: dwc3: gadget: Check for NULL descriptor To: Felipe Balbi , Greg Kroah-Hartman , linux-usb@vger.kernel.org Cc: John Youn , Thinh Nguyen , stable@vger.kernel.org Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org The function driver may try to enable an unconfigured endpoint. This check make sure that we do not attempt to access a NULL descriptor and crash. Cc: stable@vger.kernel.org Signed-off-by: Thinh Nguyen --- drivers/usb/dwc3/gadget.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 7f97856e6b20..00f8f079bbf2 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -619,6 +619,9 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep, unsigned int action) u32 reg; int ret; + if (!desc) + return -EINVAL; + if (!(dep->flags & DWC3_EP_ENABLED)) { ret = dwc3_gadget_start_config(dep); if (ret)