drivers: w1-gpio: Fixup uninitialised variable use in w1_gpio_probe
authorJonathan Bell <jonathan@raspberrypi.com>
Wed, 24 Jan 2024 11:13:19 +0000 (11:13 +0000)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:35:32 +0000 (11:35 +0000)
Signed-off-by: Jonathan Bell <jonathan@raspberrypi.com>
drivers/w1/masters/w1-gpio.c

index df3db72..68a1e48 100644 (file)
@@ -76,6 +76,11 @@ static int w1_gpio_probe(struct platform_device *pdev)
        enum gpiod_flags gflags = GPIOD_OUT_LOW_OPEN_DRAIN;
        int err;
 
+       master = devm_kzalloc(dev, sizeof(struct w1_bus_master),
+                       GFP_KERNEL);
+       if (!master)
+               return -ENOMEM;
+
        if (of_have_populated_dt()) {
                pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
                if (!pdata)
@@ -102,11 +107,6 @@ static int w1_gpio_probe(struct platform_device *pdev)
                return -ENXIO;
        }
 
-       master = devm_kzalloc(dev, sizeof(struct w1_bus_master),
-                       GFP_KERNEL);
-       if (!master)
-               return -ENOMEM;
-
        pdata->gpiod = devm_gpiod_get_index(dev, NULL, 0, gflags);
        if (IS_ERR(pdata->gpiod)) {
                dev_err(dev, "gpio_request (pin) failed\n");