Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3542451pxj; Mon, 24 May 2021 09:01:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJznIgLaAgo4mNbk2JY0/8or/L0rf7uNjuJSbYWW9WnWWedrOfakJwngyUzAL/+HgqyySIFE X-Received: by 2002:a05:6638:505:: with SMTP id i5mr23736797jar.141.1621872112246; Mon, 24 May 2021 09:01:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872112; cv=none; d=google.com; s=arc-20160816; b=a6wLeWkMwExcvtO1MrhIQiWkPDcRVwkwNEl0GFOSNCrGl+972ue8doLhSIT/wvaJG7 DJ/6X7Pzz1Q1qbCU/F8PqKhDDT1VSHxQPdMS7ImYv2ypcjKvWmbNmpMoGytVfqAnHYfI OJ9KUo47LY5An+9+kMF/Ktu/yvKG+PJyubxdil1rA7V79F/LMWw3lc99KTEHXXQP0Z02 4VOw8pyxMlgWlnhu+JhRotEtlClULQwU1mTM5wJi04/cU5wfsEpa41WqrEqNkSkz8X0k PGwUo1urNl/VvUTD+w2wlddaYLLxs+VmmeercWYbJJLn/vPrHK//0a+MR8648ckNxWhZ tG/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=yxKBJ0AuF8jsBmr8875upiLrd/mpfUzUvxs9rvsaVKs=; b=fBFjqZXmj5XUBJzcwIwbKZgywowgvsu7QIYAeqn5QQSIBtWW84exWJL8I7M01GkhyO qs/v+E4IytQHaQQ55g3yQcFxZmW2dVzbYFhvv6lqimF8Zy46xBw7ChkEr/0hGjMsj2dT pfaSdEO6eeULEEz+FrFP6IBn0i9PAJx4RH/K8EJQq2GxEEZ2FFlqOCWRxFtjCZYg3sYb TyS1eGl1k5p5JgFoMJgHL7GE4e9lNyRVNVwN99AnLTVPxiHaTrkAYrawCPjP0su2rUhl QOKCUjWL3Af/4MDBUCff4Wu3N+57LJdqCPLIbMIFGjbaTmXiJlFNGrdcW9XhjJu7cxFg MR2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QBTOkzrN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r17si8856987ilq.4.2021.05.24.09.01.37; Mon, 24 May 2021 09:01:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=QBTOkzrN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235379AbhEXQCc (ORCPT + 99 others); Mon, 24 May 2021 12:02:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:40476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234824AbhEXPzz (ORCPT ); Mon, 24 May 2021 11:55:55 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6CA761440; Mon, 24 May 2021 15:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870942; bh=rZ/38g1hb4SRg5jk+Rv+kiuvhl0QrAFnQbmRWSTca1I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QBTOkzrNfH/4zNAD9cUF/I5N11lLUy1tzFB5YXIV9KTOmmropJkJ1Mo+y8JKx8vWf Zeh0SLNtVNB2hViXkU3e65hVG15BNRG7LhATAU8kO09uFkPGNFmjMMU3KAr+gi3dyj 9Xn09rSyxgi0Mm5ak/7rnagIRwgHkZfwQnJJlJAs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Avri Altman , "Martin K. Petersen" , Phillip Potter Subject: [PATCH 5.10 089/104] scsi: ufs: handle cleanup correctly on devm_reset_control_get error Date: Mon, 24 May 2021 17:26:24 +0200 Message-Id: <20210524152335.799319845@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Phillip Potter commit 2f4a784f40f8d337d6590e2e93f46429052e15ac upstream. Move ufshcd_set_variant call in ufs_hisi_init_common to common error section at end of the function, and then jump to this from the error checking statements for both devm_reset_control_get and ufs_hisi_get_resource. This fixes the original commit (63a06181d7ce) which was reverted due to the University of Minnesota problems. Suggested-by: Greg Kroah-Hartman Cc: Avri Altman Cc: Martin K. Petersen Cc: stable Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210503115736.2104747-32-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/ufs/ufs-hisi.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) --- a/drivers/scsi/ufs/ufs-hisi.c +++ b/drivers/scsi/ufs/ufs-hisi.c @@ -478,17 +478,24 @@ static int ufs_hisi_init_common(struct u host->hba = hba; ufshcd_set_variant(hba, host); - host->rst = devm_reset_control_get(dev, "rst"); + host->rst = devm_reset_control_get(dev, "rst"); + if (IS_ERR(host->rst)) { + dev_err(dev, "%s: failed to get reset control\n", __func__); + err = PTR_ERR(host->rst); + goto error; + } ufs_hisi_set_pm_lvl(hba); err = ufs_hisi_get_resource(host); - if (err) { - ufshcd_set_variant(hba, NULL); - return err; - } + if (err) + goto error; return 0; + +error: + ufshcd_set_variant(hba, NULL); + return err; } static int ufs_hi3660_init(struct ufs_hba *hba)