Skip to contentSkip to conversation

Patch "mux: core: fix double get_device()" has been added to the 4.14-stable tree

PATCH [email protected] 1 participant 1 message Jan 14, 2018

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

mux: core: fix double get_device()

to the 4.14-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mux-core-fix-double-get_device.patch
and it can be found in the queue-4.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From aa1f10e85b0ab53dee85d8e293c8159d18d293a8 Mon Sep 17 00:00:00 2001

From: Hans de Goede <[email protected]>
Date: Fri, 29 Dec 2017 00:22:54 +0100
Subject: mux: core: fix double get_device()

From: Hans de Goede <[email protected]>

commit aa1f10e85b0ab53dee85d8e293c8159d18d293a8 upstream.

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).

---
 drivers/mux/core.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/mux/core.c +3 -1
@@ -413,6 +413,7 @@ static int of_dev_node_match(struct devi
 	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)
 {
 	struct device *dev;
@@ -466,6 +467,7 @@ struct mux_control *mux_control_get(stru
 	    (!args.args_count && (mux_chip->controllers > 1))) {
 		dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n",
 			np, args.np);
+		put_device(&mux_chip->dev);
 		return ERR_PTR(-EINVAL);
 	}
 
@@ -476,10 +478,10 @@ struct mux_control *mux_control_get(stru
 	if (controller >= mux_chip->controllers) {
 		dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n",
 			np, controller, args.np);
+		put_device(&mux_chip->dev);
 		return ERR_PTR(-EINVAL);
 	}
 
-	get_device(&mux_chip->dev);
 	return &mux_chip->mux[controller];
 }
 EXPORT_SYMBOL_GPL(mux_control_get);

Patches currently in stable-queue which might be from [email protected] are

queue-4.14/uas-ignore-uas-for-norelsys-ns1068-x-chips.patch queue-4.14/mux-core-fix-double-get_device.patch