Received: by 10.223.176.46 with SMTP id f43csp273010wra; Tue, 23 Jan 2018 20:47:37 -0800 (PST) X-Google-Smtp-Source: AH8x224wWnhoS7sUWQ78LqP8LdZHSaD5xOkRyZN8ddahKIedj+kBqe/+/YavSpnlRM7gA1UW1HKx X-Received: by 2002:a17:902:8506:: with SMTP id bj6-v6mr5311776plb.24.1516769257241; Tue, 23 Jan 2018 20:47:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516769257; cv=none; d=google.com; s=arc-20160816; b=t9j5hQZoOOdFrOWFAnyxwWlXsiVMKH/jZORLauCVhJdqzXlbkKCPT8mtQ0IHoGKulH 7KjgkquvwOon4Hl8OfCHaNE8oWYBNFfgMPg0X4GaAKMQM0XyIzWE6teU45uxRRHWlWdr u9bEWKS6eqaAxXjRpsbVZU7F1r2iAJqliPldoW3MjXVyM3N372tPU3jD6hgNQpFF5j+O gUYgAu4I1bfunDjaCpSBnE8s5Rg+Gna/fBSnnH0TTIoeKPsm9LFvG/0jvL/FsSZkVnPR Glqf+Z5RxLfe1OviiSpLuQpqokPgb2OaBzKoH40sDQ++LsTsMsidHw4/i0CWi5GIbzKo PcBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=PUKnJ4e127IkCoxj+0+ZHkIEdO/lp6vQ8uopkgyEY7U=; b=QTsKM42CaQgv1tE9jdv4SvrMRuKdgbl0k5QdljoXOmUFJRkG7u5GhwNrDdxeHn6Y8A IH8k1tUeD+EHmPSxr3iJ+iax7E5zbCt0zGbazABNjxZWj0jRTjdU2psOL+nyUVGMnWpL DDQybdodlKrXulHQVwuEo9JNeTxxVP9M18fSC8KrijDoTiL1t+nHIV1YGt+n2XIt2tAg 1WqGlmOy55JF1RGWM6qt0FcTIkSt/+wFv/ogmRMuOWefd4F3jHRqnmbnSS4t+mNpJXSS h3KADGJAXIZ8VZD1oycv1zsml5UKep9TEjx6d7YNM7HJhOcyAW+qLcXT90eZTNmaEg5Z q3QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=HHRGMHia; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bi1-v6si4380692plb.45.2018.01.23.20.47.23; Tue, 23 Jan 2018 20:47:37 -0800 (PST) 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=@microsoft.com header.s=selector1 header.b=HHRGMHia; 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=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932756AbeAXEq5 (ORCPT + 99 others); Tue, 23 Jan 2018 23:46:57 -0500 Received: from mail-sn1nam01on0139.outbound.protection.outlook.com ([104.47.32.139]:26809 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932598AbeAXEQk (ORCPT ); Tue, 23 Jan 2018 23:16:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PUKnJ4e127IkCoxj+0+ZHkIEdO/lp6vQ8uopkgyEY7U=; b=HHRGMHiajK9GRZeVlMsgF1YyabP1jSc6XCmOmeZs3BpTVrX+oQ3MM3nxycXPNEprp/cHaVWZb1xunSULkQZXUPZB4JCccWzXhpmT1U2+c2sDDNg4NiDW0znzBYYaYwBh1JXIm/plNFHNIxXyO567kvXsK72v6Pm7MMZ2oWaDNFo= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB0727.namprd21.prod.outlook.com (10.167.110.39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.464.1; Wed, 24 Jan 2018 04:16:38 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::6485:b98:d15e:9da7%2]) with mapi id 15.20.0464.000; Wed, 24 Jan 2018 04:16:38 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: "Gustavo A. R. Silva" , "Martin K . Petersen" , Sasha Levin Subject: [PATCH AUTOSEL for 4.14 092/100] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg Thread-Topic: [PATCH AUTOSEL for 4.14 092/100] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg Thread-Index: AQHTlMnuf5WuJCDtsE+27+CKIQe2uA== Date: Wed, 24 Jan 2018 04:15:13 +0000 Message-ID: <20180124041414.32065-92-alexander.levin@microsoft.com> References: <20180124041414.32065-1-alexander.levin@microsoft.com> In-Reply-To: <20180124041414.32065-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB0727;7:t4sTC+LZ+gINtzK1p3wJlijtpwBDmQJQKAZruAU29JH+NXeuiHF3f8pxCoNVzwIQqRceY8IP3Oofd4DStjfoWGNKQ7NlULK6qg44xJ08FJ+q/g3dt4YsKw9c5oQ4CbqjS8zXH07ZQIRKxb7sQLFsbfhmBm672N7QeMTXh/mIYSOT0JdION7kHlTvmO7sCqPTPAy5abbCWmnhbHp9L2yMKYCEIUNCtu6LKrm7Tjv6SuKX3VN7cSOSsQDDzrwLayUq x-ms-office365-filtering-correlation-id: 8a74a26e-781f-43b3-497a-08d562e14380 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(2017052603307)(7193020);SRVR:DM5PR2101MB0727; x-ms-traffictypediagnostic: DM5PR2101MB0727: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(146099531331640); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(61425038)(6040501)(2401047)(5005006)(8121501046)(3231046)(2400081)(944501161)(3002001)(93006095)(93001095)(10201501046)(6055026)(61426038)(61427038)(6041288)(20161123560045)(20161123558120)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DM5PR2101MB0727;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB0727; x-forefront-prvs: 056297E276 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(346002)(396003)(366004)(39380400002)(39860400002)(376002)(189003)(199004)(86612001)(6506007)(106356001)(76176011)(6346003)(54906003)(575784001)(86362001)(2501003)(110136005)(1076002)(7736002)(5250100002)(3660700001)(316002)(26005)(102836004)(2950100002)(6666003)(99286004)(97736004)(22452003)(107886003)(6436002)(53936002)(478600001)(66066001)(14454004)(2900100001)(6512007)(2906002)(5660300001)(8936002)(4326008)(10290500003)(305945005)(10090500001)(68736007)(25786009)(81166006)(72206003)(36756003)(8676002)(81156014)(3846002)(6116002)(3280700002)(105586002)(6486002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB0727;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: weRtx0qxWKVVa3t5ZMoRXijg7ZY6UCzcj6of1WVFVWk3exdrQoRiDUTs/OzAllBmCMrAmtWH1DXXoj/pETbviw== spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a74a26e-781f-43b3-497a-08d562e14380 X-MS-Exchange-CrossTenant-originalarrivaltime: 24 Jan 2018 04:15:13.4696 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB0727 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: "Gustavo A. R. Silva" [ Upstream commit 727535903bea924c4f73abb202c4b3e85fff0ca4 ] _vreg_ is being dereferenced before it is null checked, hence there is a potential null pointer dereference. Fix this by moving the pointer dereference after _vreg_ has been null checked. This issue was detected with the help of Coccinelle. Fixes: aa4976130934 ("ufs: Add regulator enable support") Signed-off-by: Gustavo A. R. Silva Reviewed-by: Subhash Jadavani Signed-off-by: Martin K. Petersen Signed-off-by: Sasha Levin --- drivers/scsi/ufs/ufshcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 794a4600e952..d344fef01f1d 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6555,12 +6555,15 @@ static int ufshcd_config_vreg(struct device *dev, struct ufs_vreg *vreg, bool on) { int ret =3D 0; - struct regulator *reg =3D vreg->reg; - const char *name =3D vreg->name; + struct regulator *reg; + const char *name; int min_uV, uA_load; =20 BUG_ON(!vreg); =20 + reg =3D vreg->reg; + name =3D vreg->name; + if (regulator_count_voltages(reg) > 0) { min_uV =3D on ? vreg->min_uV : 0; ret =3D regulator_set_voltage(reg, min_uV, vreg->max_uV); --=20 2.11.0