From patchwork Thu Mar 29 11:04:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manu Gautam X-Patchwork-Id: 10314935 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A0CD960353 for ; Thu, 29 Mar 2018 11:07:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 97C022A2ED for ; Thu, 29 Mar 2018 11:07:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95C842A318; Thu, 29 Mar 2018 11:07:35 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 221E62A317 for ; Thu, 29 Mar 2018 11:07:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752584AbeC2LGV (ORCPT ); Thu, 29 Mar 2018 07:06:21 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43542 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752209AbeC2LGT (ORCPT ); Thu, 29 Mar 2018 07:06:19 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 096FD60C54; Thu, 29 Mar 2018 11:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522321579; bh=wY1u/y7YYuZyKb5K1mf2Z6OpsGfhhFaI8QOi9PLKQfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T2/HxlgqHAfBQy6hO1WBm9Fe6Q6CVgeV/DWF04EUqaagibqPBBzP+cKu0BrtuA4CD cZRsu8fiNtd2QV0sNYZXHanndOYQjnUVmBrGiax9qDNOcC/bmDWEuG5tUDGncfndxq aDPUcfzz5Gln8nY/MRqk6bNUpe04xZMki77pdT4A= Received: from mgautam-linux.qualcomm.com (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mgautam@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 161BF601D3; Thu, 29 Mar 2018 11:06:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1522321577; bh=wY1u/y7YYuZyKb5K1mf2Z6OpsGfhhFaI8QOi9PLKQfo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WyBuu7gjiyZpy+2tFjQcBEzWCIp+y0HRyoQ6Phw24m3NLfikq0INrDFTcI7ZUjaxe fL/pTPjfKD6Bp8SJ3Q5qqiCptDrU2VojbPELjFAZSG92bX4AjUPJ2n6+/R0ymGQhtS SNARySVKMOaPTwTt0JVNyaAE+OyHsz4TkW9qMeyc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 161BF601D3 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mgautam@codeaurora.org From: Manu Gautam To: Kishon Vijay Abraham I , robh@kernel.org, sboyd@codeaurora.org Cc: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, robh+dt@kernel.org, vivek.gautam@codeaurora.org, evgreen@chromium.org, dianders@chromium.org, linux-arm-msm@vger.kernel.org, Manu Gautam , stable , Yoshihiro Shimoda Subject: [PATCH v4 3/7] phy: qcom-qusb2: Fix crash if nvmem cell not specified Date: Thu, 29 Mar 2018 16:34:22 +0530 Message-Id: <1522321466-21755-4-git-send-email-mgautam@codeaurora.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1522321466-21755-1-git-send-email-mgautam@codeaurora.org> References: <1522321466-21755-1-git-send-email-mgautam@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Driver currently crashes due to NULL pointer deference while updating PHY tune register if nvmem cell is NULL. Since, fused value for Tune1/2 register is optional, we'd rather bail out. Fixes: ca04d9d3e1b1 ("phy: qcom-qusb2: New driver for QUSB2 PHY on Qcom chips") Reviewed-by: Vivek Gautam Reviewed-by: Evan Green Cc: stable # 4.14+ Signed-off-by: Manu Gautam --- drivers/phy/qualcomm/phy-qcom-qusb2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qusb2.c b/drivers/phy/qualcomm/phy-qcom-qusb2.c index 94afeac..40fdef8 100644 --- a/drivers/phy/qualcomm/phy-qcom-qusb2.c +++ b/drivers/phy/qualcomm/phy-qcom-qusb2.c @@ -315,6 +315,10 @@ static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy) const struct qusb2_phy_cfg *cfg = qphy->cfg; u8 *val; + /* efuse register is optional */ + if (!qphy->cell) + return; + /* * Read efuse register having TUNE2/1 parameter's high nibble. * If efuse register shows value as 0x0, or if we fail to find