From: Hans de Goede <hdegoede@redhat.com>
To: Peter Rosin <peda@axentia.se>
Cc: Hans de Goede <hdegoede@redhat.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-kernel@vger.kernel.org
Subject: [PATCH] mux: core: Fix double get_device()
Date: Thu, 31 Aug 2017 17:22:45 +0200 [thread overview]
Message-ID: <20170831152245.14502-1-hdegoede@redhat.com> (raw)
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).
Also rename of_find_mux_chip_by_node to of_get_mux_chip_by_node to
make it clear that it returns a reference.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
drivers/mux/core.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/mux/core.c b/drivers/mux/core.c
index 7aa656ac8fb5..8864cc745506 100644
--- a/drivers/mux/core.c
+++ b/drivers/mux/core.c
@@ -433,7 +433,7 @@ static int of_dev_node_match(struct device *dev, const void *data)
return dev->of_node == data;
}
-static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np)
+static struct mux_chip *of_get_mux_chip_by_node(struct device_node *np)
{
struct device *dev;
@@ -471,7 +471,7 @@ static struct mux_control *of_mux_control_get(struct device *dev,
return ERR_PTR(ret);
}
- mux_chip = of_find_mux_chip_by_node(args.np);
+ mux_chip = of_get_mux_chip_by_node(args.np);
of_node_put(args.np);
if (!mux_chip)
return ERR_PTR(-EPROBE_DEFER);
@@ -480,6 +480,7 @@ static struct mux_control *of_mux_control_get(struct device *dev,
(!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);
}
@@ -490,10 +491,10 @@ static struct mux_control *of_mux_control_get(struct device *dev,
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];
}
--
2.13.4
next reply other threads:[~2017-08-31 15:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-31 15:22 Hans de Goede [this message]
2017-08-31 21:57 ` Peter Rosin
2017-12-28 23:22 [PATCH] mux: core: fix " Peter Rosin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170831152245.14502-1-hdegoede@redhat.com \
--to=hdegoede@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peda@axentia.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®