Received: by 10.223.176.5 with SMTP id f5csp991897wra; Fri, 2 Feb 2018 09:21:42 -0800 (PST) X-Google-Smtp-Source: AH8x227tv2dV51Jm6vMifz5MdVgXzMSvE29K4FAIkGR1YhV333p3jl4jSak552uNCTCduB5/neE+ X-Received: by 2002:a17:902:9893:: with SMTP id s19-v6mr6957186plp.101.1517592101952; Fri, 02 Feb 2018 09:21:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517592101; cv=none; d=google.com; s=arc-20160816; b=nDpishLuzxbOo2tti+09PjbHanjlPmPWiQ2uQS+geWH1/uRJnBxIpuT5mSG/olhbwk 3//DmI276vh0ksdRfhg5ypnDZPj5x22ejldKUMS365b8IVA4LcyI7gDyzuaX/W/k0fQf KgVZlIIrqbWzCTfIV71/5R0UihcewHWDJddqya7dPj2cqcF7sWrs2458duIOGd0ABfWR bbZXmL/geskskCYx2HNX9DNJOKQpnwWx4aa3xmnt6n+hM3sbv/Ntjpgf7OFpKYcA+VXb zPthgIv0zISWby4pI4THHOdm+AYXgnEYfbiZt0eitIUFuQlHAuFtpWVzXNDusKaK431s MHtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=epReIyLiXyI7k2IlkRoLeslHd/axOrMKMxQdp5x3JwM=; b=t7zKKStOBKRohy23h4pfcVQUxpEiRNs8KWeyoVMyFg3YalUdGfrXvCB6hhHwccFzny D1ix26EhJqs1euS1byH9IneI6beII4QBQbISJ2s8Uc8EXOshdYFf17JvB4hWlEuj/XTd klNn8xYcr516iTkKuDL8ksVvxep3+KXazuGga/FdIh/RcnYEa68+46xLuis9gqCpXJiC OqJHScukNR5TOWvdaUWKGaBVs9ZoUHA22+bHRjRx8JM4c62goSL+xkFo3QDYmMcWBwnT w+xb3ZZkJhyzzROyQdatm014ZDrPQ1tZ4SNKD4Czw26V1mODx0fVFGd0783mhLWQ9uXt vp1Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12-v6si2097452pln.737.2018.02.02.09.21.27; Fri, 02 Feb 2018 09:21:41 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753802AbeBBRUY (ORCPT + 99 others); Fri, 2 Feb 2018 12:20:24 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:39016 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbeBBRM2 (ORCPT ); Fri, 2 Feb 2018 12:12:28 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3A82AF24; Fri, 2 Feb 2018 17:12:27 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Gustavo A. R. Silva" , Subhash Jadavani , "Martin K. Petersen" , Sasha Levin Subject: [PATCH 4.14 118/156] scsi: ufs: ufshcd: fix potential NULL pointer dereference in ufshcd_config_vreg Date: Fri, 2 Feb 2018 17:58:19 +0100 Message-Id: <20180202140845.524006441@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180202140840.242829545@linuxfoundation.org> References: <20180202140840.242829545@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ufs/ufshcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -6555,12 +6555,15 @@ static int ufshcd_config_vreg(struct dev struct ufs_vreg *vreg, bool on) { int ret = 0; - struct regulator *reg = vreg->reg; - const char *name = vreg->name; + struct regulator *reg; + const char *name; int min_uV, uA_load; BUG_ON(!vreg); + reg = vreg->reg; + name = vreg->name; + if (regulator_count_voltages(reg) > 0) { min_uV = on ? vreg->min_uV : 0; ret = regulator_set_voltage(reg, min_uV, vreg->max_uV);