Commit aa1f10e8 authored by Hans de Goede's avatar Hans de Goede Committed by Greg Kroah-Hartman

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: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarPeter Rosin <peda@axentia.se>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 06e7e776
...@@ -413,6 +413,7 @@ static int of_dev_node_match(struct device *dev, const void *data) ...@@ -413,6 +413,7 @@ static int of_dev_node_match(struct device *dev, const void *data)
return dev->of_node == data; return dev->of_node == data;
} }
/* Note this function returns a reference to the mux_chip dev. */
static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np) static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np)
{ {
struct device *dev; struct device *dev;
...@@ -466,6 +467,7 @@ struct mux_control *mux_control_get(struct device *dev, const char *mux_name) ...@@ -466,6 +467,7 @@ struct mux_control *mux_control_get(struct device *dev, const char *mux_name)
(!args.args_count && (mux_chip->controllers > 1))) { (!args.args_count && (mux_chip->controllers > 1))) {
dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n", dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n",
np, args.np); np, args.np);
put_device(&mux_chip->dev);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
...@@ -476,10 +478,10 @@ struct mux_control *mux_control_get(struct device *dev, const char *mux_name) ...@@ -476,10 +478,10 @@ struct mux_control *mux_control_get(struct device *dev, const char *mux_name)
if (controller >= mux_chip->controllers) { if (controller >= mux_chip->controllers) {
dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n", dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n",
np, controller, args.np); np, controller, args.np);
put_device(&mux_chip->dev);
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
} }
get_device(&mux_chip->dev);
return &mux_chip->mux[controller]; return &mux_chip->mux[controller];
} }
EXPORT_SYMBOL_GPL(mux_control_get); EXPORT_SYMBOL_GPL(mux_control_get);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment