From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52FF48F57 for ; Sun, 16 Jul 2023 20:51:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBC94C433C8; Sun, 16 Jul 2023 20:51:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1689540672; bh=dcZe0kwwzgnQiIyhOpmQ+jtE7EzkbofqGzpTj2WWe58=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WUehK6hVlkfFUrBS46MId2cSBCg0vZsYyGCwow3sYd1mAOJ9wMS0ht4jgN75fwJx2 1aiewUj8J1R7i7MbEwdO3ydfq3bjG/JOhcPxwCRrY/7EDTbfIajCcRVMFxuqQ9gEQI hbwX+hjvyWd5PdjHjqrngum5JJd327hzzv9fSQUg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Amelie Delaunay , Lee Jones , Sasha Levin Subject: [PATCH 6.1 447/591] mfd: stmfx: Nullify stmfx->vdd in case of error Date: Sun, 16 Jul 2023 21:49:46 +0200 Message-ID: <20230716194935.473307142@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230716194923.861634455@linuxfoundation.org> References: <20230716194923.861634455@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Amelie Delaunay [ Upstream commit 7c81582c0bccb4757186176f0ee12834597066ad ] Nullify stmfx->vdd in case devm_regulator_get_optional() returns an error. And simplify code by returning an error only if return code is not -ENODEV, which means there is no vdd regulator and it is not an issue. Fixes: d75846ed08e6 ("mfd: stmfx: Fix dev_err_probe() call in stmfx_chip_init()") Signed-off-by: Amelie Delaunay Link: https://lore.kernel.org/r/20230609092804.793100-2-amelie.delaunay@foss.st.com Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/stmfx.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/mfd/stmfx.c b/drivers/mfd/stmfx.c index 61a8aad564a4e..b1ecd85ad2a8a 100644 --- a/drivers/mfd/stmfx.c +++ b/drivers/mfd/stmfx.c @@ -330,9 +330,8 @@ static int stmfx_chip_init(struct i2c_client *client) stmfx->vdd = devm_regulator_get_optional(&client->dev, "vdd"); ret = PTR_ERR_OR_ZERO(stmfx->vdd); if (ret) { - if (ret == -ENODEV) - stmfx->vdd = NULL; - else + stmfx->vdd = NULL; + if (ret != -ENODEV) return dev_err_probe(&client->dev, ret, "Failed to get VDD regulator\n"); } -- 2.39.2