]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
can: tcan4x5x: fix power regulator retrieval during probe
authorBrett Werling <brett.werling@garmin.com>
Thu, 12 Jun 2025 19:18:25 +0000 (14:18 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 17 Jul 2025 16:27:39 +0000 (18:27 +0200)
[ Upstream commit db22720545207f734aaa9d9f71637bfc8b0155e0 ]

Fixes the power regulator retrieval in tcan4x5x_can_probe() by ensuring
the regulator pointer is not set to NULL in the successful return from
devm_regulator_get_optional().

Fixes: 3814ca3a10be ("can: tcan4x5x: tcan4x5x_can_probe(): turn on the power before parsing the config")
Signed-off-by: Brett Werling <brett.werling@garmin.com>
Link: https://patch.msgid.link/20250612191825.3646364-1-brett.werling@garmin.com
Cc: stable@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/can/m_can/tcan4x5x.c

index f903f78af087aac740277361c2fd88c738d36564..4bdea945c4862311a3d8a12802a72ba20f43ce09 100644 (file)
@@ -417,10 +417,11 @@ static int tcan4x5x_can_probe(struct spi_device *spi)
        }
 
        priv->power = devm_regulator_get_optional(&spi->dev, "vsup");
-       if (PTR_ERR(priv->power) == -EPROBE_DEFER) {
-               ret = -EPROBE_DEFER;
-               goto out_m_can_class_free_dev;
-       } else {
+       if (IS_ERR(priv->power)) {
+               if (PTR_ERR(priv->power) == -EPROBE_DEFER) {
+                       ret = -EPROBE_DEFER;
+                       goto out_m_can_class_free_dev;
+               }
                priv->power = NULL;
        }