From patchwork Wed Apr 15 19:10:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 6222421 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5C642BF4A6 for ; Wed, 15 Apr 2015 19:11:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 872DA2012D for ; Wed, 15 Apr 2015 19:11:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9D23A2010C for ; Wed, 15 Apr 2015 19:11:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933404AbbDOTK7 (ORCPT ); Wed, 15 Apr 2015 15:10:59 -0400 Received: from seldrel01.sonyericsson.com ([212.209.106.2]:8232 "EHLO seldrel01.sonyericsson.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932658AbbDOTK5 (ORCPT ); Wed, 15 Apr 2015 15:10:57 -0400 From: Bjorn Andersson To: Vinayak Holikatti , "James E.J. Bottomley" , Mark Brown CC: Akinobu Mita , , Subject: [PATCH] ufs: Reinstate NULL pointer checks for regulators Date: Wed, 15 Apr 2015 12:10:53 -0700 Message-ID: <1429125053-31825-1-git-send-email-bjorn.andersson@sonymobile.com> X-Mailer: git-send-email 1.8.2.2 MIME-Version: 1.0 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The cleanup during the introduction of regulator_set_load() was a too optimistic and re-opened an issue with vreg being dereferenced while being NULL. So reinstate the NULL checks and add back the BUG_ON() to follow the general coding convention of the implementation. Fixes: 7b16a07c3293 ("ufs: Rename of regulator_set_optimum_mode") Reported-by: Akinobu Mita Signed-off-by: Bjorn Andersson Tested-by: Akinobu Mita --- drivers/scsi/ufs/ufshcd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 648a44675880..540e00df6de1 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4262,8 +4262,7 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, { int ret; - if (!vreg) - return 0; + BUG_ON(!vreg); ret = regulator_set_load(vreg->reg, ua); if (ret < 0) { @@ -4277,12 +4276,18 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg, static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba, struct ufs_vreg *vreg) { + if (!vreg) + return 0; + return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA); } static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba, struct ufs_vreg *vreg) { + if (!vreg) + return 0; + return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA); }