iio: frequency: adf4350: disable reg and clk on error in adf4350_probe()
authorYang Yingliang <yangyingliang@huawei.com>
Tue, 1 Jun 2021 14:26:05 +0000 (22:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Jul 2021 14:55:44 +0000 (16:55 +0200)
commit c8cc4cf60b000fb9f4b29bed131fb6cf1fe42d67 upstream.

Disable reg and clk when devm_gpiod_get_optional() fails in adf4350_probe().

Fixes:4a89d2f47ccd ("iio: adf4350: Convert to use GPIO descriptor")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20210601142605.3613605-1-yangyingliang@huawei.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iio/frequency/adf4350.c

index 82c050a3899d9f4f2558339979fd0ec7df7c6680..8f885b0af38e5c09320c7625c27e8eea14a3703f 100644 (file)
@@ -563,8 +563,10 @@ static int adf4350_probe(struct spi_device *spi)
 
        st->lock_detect_gpiod = devm_gpiod_get_optional(&spi->dev, NULL,
                                                        GPIOD_IN);
-       if (IS_ERR(st->lock_detect_gpiod))
-               return PTR_ERR(st->lock_detect_gpiod);
+       if (IS_ERR(st->lock_detect_gpiod)) {
+               ret = PTR_ERR(st->lock_detect_gpiod);
+               goto error_disable_reg;
+       }
 
        if (pdata->power_up_frequency) {
                ret = adf4350_set_freq(st, pdata->power_up_frequency);