mux: core: fix double get_device()

class_find_device already does a get_device on the returned device.
So the device returned by of_find_mux_chip_by_node is already referenced
and we should not reference it again (and unref it on error).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by Hans de Goede and committed by Greg Kroah-Hartman aa1f10e8 06e7e776

+3 -1
+3 -1
drivers/mux/core.c
··· 413 return dev->of_node == data; 414 } 415 416 static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) 417 { 418 struct device *dev; ··· 467 (!args.args_count && (mux_chip->controllers > 1))) { 468 dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n", 469 np, args.np); 470 return ERR_PTR(-EINVAL); 471 } 472 ··· 478 if (controller >= mux_chip->controllers) { 479 dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n", 480 np, controller, args.np); 481 return ERR_PTR(-EINVAL); 482 } 483 484 - get_device(&mux_chip->dev); 485 return &mux_chip->mux[controller]; 486 } 487 EXPORT_SYMBOL_GPL(mux_control_get);
··· 413 return dev->of_node == data; 414 } 415 416 + /* Note this function returns a reference to the mux_chip dev. */ 417 static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) 418 { 419 struct device *dev; ··· 466 (!args.args_count && (mux_chip->controllers > 1))) { 467 dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n", 468 np, args.np); 469 + put_device(&mux_chip->dev); 470 return ERR_PTR(-EINVAL); 471 } 472 ··· 476 if (controller >= mux_chip->controllers) { 477 dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n", 478 np, controller, args.np); 479 + put_device(&mux_chip->dev); 480 return ERR_PTR(-EINVAL); 481 } 482 483 return &mux_chip->mux[controller]; 484 } 485 EXPORT_SYMBOL_GPL(mux_control_get);