Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3549814pxj; Mon, 24 May 2021 09:09:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiAtNArAtef/vJchoyKFEw4zNsg7zD5VzbA8f96Y8juz1hlAXlNl/j04wYKyMthXtAZUat X-Received: by 2002:aa7:dbc9:: with SMTP id v9mr26571974edt.183.1621872581625; Mon, 24 May 2021 09:09:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872581; cv=none; d=google.com; s=arc-20160816; b=jfwmxWHDanmhp1fz46LLGEYin/QubRzEU7Nu63pkTeFETWMdvIGKdZhbsfJwv1x36t kV97E3TtSjnACzC9MVyLR0NJxjgeYuZJxfyqHJCXXcByk1Kxn1pJOqSbt8h7CFqrR2OU chXHOtfZp99N8HYnb0m5wMkUGTvUt9YYYr9rt62KiLvbCILS/Dydg1ekr3Aq6m9eYF/h KUWOEm36yqjt2W2cfx5UyfQWFNLdi7c11Hz/pwRnZCb6AEhJaiA2gvIY6fhXHEaP5uH7 OCFejY10/8NTDYDtDjXTqAT9Iew5fiFzFjBeHyo0bfHCvfZwTjL2h9GtQM3t8y6OQJDc EFVA== 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=TUuV++ZXURgP1zwzmlJVe4T6Fd3XpNTmOd84aRqLQww=; b=D3Zf0O2FWFvNJI0pqpqucAypTwJu7+fLgqT74pwgMIlGZVnfiECJStnnZ7JlrXpjU6 QfKloqYEURNedYDmXLtoNv5br26huFH5NTnOmvjOvucz9WGZiWo9mDdo1XZvIrnR3iFg o805k/L0TnnGnPiBfJJWnzoXFCcPqvgC11D7qA2HkpOi45N37XPlwdZ8bY0qebHBHDv5 YoTknD6fh0QisXErc9lg5kzJ9tl3mYlFSy18cayRjO28kMQbj1DWB28EGQ2OZ+H3t1uP oxss0pDjX3r59nFgD9qfN1N96Wg4K1T9vtk/QPgqpyJqJM0yY7r0bPwoq1g/3YDhwi31 izTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JzkpgtMg; 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 cd8si14446696ejb.132.2021.05.24.09.09.18; Mon, 24 May 2021 09:09:41 -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=JzkpgtMg; 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 S236617AbhEXQIx (ORCPT + 99 others); Mon, 24 May 2021 12:08:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:47738 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234950AbhEXQA4 (ORCPT ); Mon, 24 May 2021 12:00:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 12CE56145E; Mon, 24 May 2021 15:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621871183; bh=BN8zh1LNWtn46gjnWqsOuRxrTaOFoXgY1kqUSV7FGvc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JzkpgtMgEFkDKm8SyoETzy+RsWHessLK+h2zlRLFiQcujFYxhseAuTOLMe06DQTXC GJSLmIL/dPmQ70bfWi2KJyib3g0lhCf82eFf4Em/FxeRKcjto6o86USxksMW9N1NhU uB6Ta1DcPCxd9BdKAdArKffviAuetjHp3DePWclE= 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.12 112/127] scsi: ufs: handle cleanup correctly on devm_reset_control_get error Date: Mon, 24 May 2021 17:27:09 +0200 Message-Id: <20210524152338.645346706@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152334.857620285@linuxfoundation.org> References: <20210524152334.857620285@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 @@ -467,17 +467,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)