return -ENOMEM;
 
        platform_set_drvdata(pdev, priv);
-       mutex_init(&priv->lock);
        priv->base = base;
        priv->regmap = dev_get_regmap(dev->parent, NULL);
        if (!priv->regmap) {
                err = of_property_read_u32(child, "reg", ®);
                if (err) {
                        of_node_put(child);
-                       mutex_destroy(&priv->lock);
                        return err;
                }
 
                if (reg >= SC27XX_LEDS_MAX || priv->leds[reg].active) {
                        of_node_put(child);
-                       mutex_destroy(&priv->lock);
                        return -EINVAL;
                }
 
                priv->leds[reg].active = true;
        }
 
+       mutex_init(&priv->lock);
+
        err = sc27xx_led_register(dev, priv);
        if (err)
                mutex_destroy(&priv->lock);