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