From patchwork Mon Aug 28 11:02:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "\(Exiting\) Baolin Wang" X-Patchwork-Id: 111141 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp4671685qge; Mon, 28 Aug 2017 04:03:51 -0700 (PDT) X-Received: by 10.99.112.20 with SMTP id l20mr176220pgc.422.1503918231642; Mon, 28 Aug 2017 04:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503918231; cv=none; d=google.com; s=arc-20160816; b=s4r4Iqvcc0sCMWFRwDDNAbvzVzYZWtrOafCWBgKItjSdvKbBQ6F13+VAocQWQOTCem lcWYwOcyr5brquECGLw98nMxB9wDjjWc07bjxsOCuVG/D4j+jeIhYB3PqIP+UptwhuxZ eN02/MiIpyW6uSLheoui2Sv8y5Vg5WZ7RPa66FKdwhNiBp8vNvB4Qxdqa680S4XVj2Wr WL6wFfpDYvNGpIrs51PrAgvMei1dtZx/n9BYCECWNAzWpq/Up7BGcmVr6aFApX11ZgK0 ozhslXOfxJxQYZ8j7ojNp7xaCrNjhZbYBNu/zfaVFJtVV6IlxT2+Xj51llDZO+4zY6n7 yAWA== 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:arc-authentication-results; bh=DBui2f1KYCC0h1euwgZUhKj1/vx6t8JhFVPdvbPMCMM=; b=m7+WcIQhEkweoCoCuphvAVRtNwt1VbVCw696r6iZlAGQwtA1KJjKXl0nmdH8DdiFik BqOGB7Ylya3Y+Fua9qn/GBB9P75h8CgYAccAICMm9rNWlGgJP/N3pJJ6J2toRCsj3Q+Z aDEUmwznGSCRMH0muuejmwfYnE7UIOrpHPXRY1TDBUpft3Cs6lj7HIV4R0Z10g8lNUxo HF5TYo0f34ksbMM+6dyRYMlkpPsIQWLXmrXAfIlwrRa1ru5ddrcm0fJ4wqmQr+XcQ39k W0o08IfOcUxz99uMBEQPXFAaZP7CdeamgHE225gy3COFbyVmKD+BgxQx75PQq+jrEaQd l+CA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=a+G9H0W5; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 90si120423plb.338.2017.08.28.04.03.51; Mon, 28 Aug 2017 04:03:51 -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=@linaro.org header.s=google header.b=a+G9H0W5; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751302AbdH1LDt (ORCPT + 26 others); Mon, 28 Aug 2017 07:03:49 -0400 Received: from mail-pg0-f43.google.com ([74.125.83.43]:36820 "EHLO mail-pg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751157AbdH1LDr (ORCPT ); Mon, 28 Aug 2017 07:03:47 -0400 Received: by mail-pg0-f43.google.com with SMTP id r133so474143pgr.3 for ; Mon, 28 Aug 2017 04:03:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=DBui2f1KYCC0h1euwgZUhKj1/vx6t8JhFVPdvbPMCMM=; b=a+G9H0W5PhJpj3AjvXZ/z8RZ/7E5/f/x3LcH0IFVnMkE+LS+OI0hpfYoL8zW0+Wt++ apG6NOjj17rUnmUpYLxJ30EfOv+UNEe9rUglL5Tfe8W0UmphU+48oY3eGQ7HI9A8My/i 9jogD/AoV5QnpHX91srVqkMZ2+4MuvHvyfrIY= 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=DBui2f1KYCC0h1euwgZUhKj1/vx6t8JhFVPdvbPMCMM=; b=BPnKcsymFALsy3PINcHGhsU5d70qif9i+LbAuPWoMnYeLNYDLtiYsXI5vywmO2LkYl nT1XE9ILpPL77YeOmSk2eB4jkxuXxOcaelyaKuTjRmbiW6Cl3iOoVcFmgdSWTIGWiEc0 QnKSG9BcohMsqJuucByCe2U2S4OKDksH4i2WKLFCsXk2qhyoo8VW4VygB/6PRKXghfTM sq2ahPU6P3GOJ/+2144KKlk26G+5fTvQN69Hvondh3AH8SnZTLwEo7O60AgFH3K385EC et3mdAGmhJ4sQYQCVjvEBwBLTNCPZVMznTc774ArXYHwn4FQEOW7pyMurqAFpekAAzJp XkLw== X-Gm-Message-State: AHYfb5hg8QLHM7qIZuSwaomeWOyvKVkhOmLxrya2yfkEo/vdxPLIDabj Dr+IKFKtbo1AZnC0 X-Received: by 10.99.119.201 with SMTP id s192mr121689pgc.227.1503918227117; Mon, 28 Aug 2017 04:03:47 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id w64sm305183pfi.75.2017.08.28.04.03.44 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Aug 2017 04:03:46 -0700 (PDT) From: Baolin Wang To: balbi@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, dan.carpenter@oracle.com, broonie@kernel.org, baolin.wang@linaro.org Subject: [PATCH] usb: phy: Avoid unchecked dereference warning Date: Mon, 28 Aug 2017 19:02:41 +0800 Message-Id: <7c740b51a4c307f655c4ae3003748329411313cb.1503917860.git.baolin.wang@linaro.org> X-Mailer: git-send-email 1.7.9.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the USB phy NULL checking before issuing usb_phy_set_charger_current() to avoid unchecked dereference warning. Signed-off-by: Baolin Wang --- include/linux/usb/phy.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) -- 1.7.9.5 diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h index de881b1..8c69148 100644 --- a/include/linux/usb/phy.h +++ b/include/linux/usb/phy.h @@ -322,9 +322,12 @@ static inline void usb_phy_set_charger_state(struct usb_phy *usb_phy, static inline int usb_phy_set_power(struct usb_phy *x, unsigned mA) { + if (!x) + return 0; + usb_phy_set_charger_current(x, mA); - if (x && x->set_power) + if (x->set_power) return x->set_power(x, mA); return 0; }