Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3180459ybi; Mon, 29 Jul 2019 02:17:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqw0OBw158ttJXHPaqIelQH4CTu7OZJ18BZnH7U/qbOQAEBRoRZYv40kbPgsuI8vVJ7+8sdP X-Received: by 2002:a65:6846:: with SMTP id q6mr64691302pgt.150.1564391848886; Mon, 29 Jul 2019 02:17:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564391848; cv=none; d=google.com; s=arc-20160816; b=D5QD1SuML6f9P2GpyVeKmRWSaicseRiVBbRyLspJf7sCx0qGXFVACg+Hk+TUVbVxeR wvTnFpTtY7bGxly2HEqfmkaH56P9gHHo7DPPOeIYma2JoUMXsZGESSZGIJCOYQD4Qijy vs1oWyIX9lEakjByjGv58c0KKrENir7vWWIFMp8AHjXeNkNIfQIGM1H/ZcrfjZMy3/db wgcpOmjIiMLcaccNAHmeUBBmib7PH9RdnYfX7kVeu9owLZdo3V0KQlE4a6vxnelKS/Eu o7Qk7ZbfW42gKFiJkJLOwbLGczVLKGDpv/PZHaEKDMMokj2/8r98DX8Fb1Tu524fJBOh iSVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=v/A21rAwjhZMNLCDz5qblCoOcY3twfiyDKBiZflQpBQ=; b=jvcg37nBFJtHRBzCq+TulIPf5a7FrxNj/JxanpCbBt7z+Yzj4DcnwnVdUYkd1OQKhm 5cEkVjk8WBQIBW2ttegq3Y4Mu2zvjVDC3p8Spt3f5JXPdndVKe/uYLZrM/2fwqI6e+Gz QYAqRU1UZS4fU3pAlTEGxHWtwfOr1ZtX0CAVxTvkLR7QjLcjcXjq2dtTKYT9pYKLFfWH pHx+6zdGRNMQHEEHwiyJY9Ta+0QVt0ix8bZOzTH3gk4PstZv3+oaqq1fRNDZIFQpiJQ8 62HFs6Xu1xie9aNayJpz7D1WRGPXKRrEwUY6qG9kjTh2XdLwgHDGgWzewWCAG9UEN5tU nbiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Dpmv/JAy"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si24740062pjb.40.2019.07.29.02.17.13; Mon, 29 Jul 2019 02:17:28 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Dpmv/JAy"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727668AbfG2JEg (ORCPT + 99 others); Mon, 29 Jul 2019 05:04:36 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42512 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726432AbfG2JEf (ORCPT ); Mon, 29 Jul 2019 05:04:35 -0400 Received: by mail-pg1-f195.google.com with SMTP id t132so27903157pgb.9; Mon, 29 Jul 2019 02:04:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=v/A21rAwjhZMNLCDz5qblCoOcY3twfiyDKBiZflQpBQ=; b=Dpmv/JAygDIespOi7yY+Pll4NwJss+4gHitbFUWYnGC8LgfvYn0OlweiqB9Vi4w2Ni XLp94Y5QJ0tSLmKin/zDMce9xpI8+S9yRgkyMEWulc+/HLE0sz8sp/Zr5IT6U7D7vpb/ oQQz9LOW0CxOBqdDk5+ThBOMpIEFQGBW5rYceBD59U9ICIKUhQ557jYViwHNcXgAHIHc L1MfSwJ/WhcHlm8Bk3AWCdp+pQKJLlf/IlmQ1ruyR7m/YBgeWk1ujfJpCUTua4Qa9uJh m+vKcvusOHAygtUf6PA3YFx7qLs3l9T2sST9dbgkkYgk2LZch1LJSs5cLD53opL8Y3Wp mSlQ== 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=v/A21rAwjhZMNLCDz5qblCoOcY3twfiyDKBiZflQpBQ=; b=Nr028G8H4GV3f+XycgII/CsuGZlgWoaYEhZ4p2EW0nc0G1xzGU1XzxTMsx0FuiSs80 Jmr5vAMCz0fUrVE1q43zy5HoD8YOgTRUVQkkm6S2trpjVDwcKcROIV6nC9CMO+7qLhCP BIauzEEvbMEsB3iqMHbWi5UbxGKfX/4g8rflJKB8JjKFRJbCWK/pe+4nz9xgSjGZuOHN CsllcJrc5MSl5HsH77sVC5MLB0f0idtF6cP9fQIcF0Nc7lLe94fWJ24oyV4dHAwt2eoe zNsjSUrJYCciOhXMCXvRr/oax8wpB5gqpm/ZSQjSKYGUynJ2M+9UjYKxpy66/LGwn0jk V20w== X-Gm-Message-State: APjAAAWXsuYgx4HydQ4owV839/FuFNz0FNFeJz4bGq+rgKm9iTm/A8FP 6eUyQjz203FNasSxUgtLd/k= X-Received: by 2002:a63:5c07:: with SMTP id q7mr50879183pgb.436.1564391074974; Mon, 29 Jul 2019 02:04:34 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:4:72:808::3ca]) by smtp.gmail.com with ESMTPSA id 30sm140861632pjk.17.2019.07.29.02.04.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Jul 2019 02:04:34 -0700 (PDT) From: Jia-Ju Bai To: b-liu@ti.com, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] usb: musb: Fix a possible null-pointer dereference in musb_handle_intr_connect() Date: Mon, 29 Jul 2019 17:04:28 +0800 Message-Id: <20190729090428.29508-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In musb_handle_intr_connect(), there is an if statement on line 783 to check whether musb->hcd is NULL: if (musb->hcd) When musb->hcd is NULL, it is used on line 797: musb_host_poke_root_hub(musb); if (musb->hcd->status_urb) Thus, a possible null-pointer dereference may occur. To fix this bug, musb->hcd is checked before calling musb_host_poke_root_hub(). This bug is found by a static analysis tool STCheck written by us. Signed-off-by: Jia-Ju Bai --- drivers/usb/musb/musb_core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 9f5a4819a744..329ff52f8167 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -794,7 +794,8 @@ static void musb_handle_intr_connect(struct musb *musb, u8 devctl, u8 int_usb) break; } - musb_host_poke_root_hub(musb); + if (musb->hcd) + musb_host_poke_root_hub(musb); musb_dbg(musb, "CONNECT (%s) devctl %02x", usb_otg_state_string(musb->xceiv->otg->state), devctl); -- 2.17.0