From: Peter Rosin <peda@axentia.se>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Peter Rosin <peda@axentia.se>, <linux-kernel@vger.kernel.org>,
<kernel-janitors@vger.kernel.org>
Subject: [PATCH] mux: core: fix error handling in devm_mux_chip_alloc
Date: Tue, 14 Mar 2017 17:49:58 +0100 [thread overview]
Message-ID: <1489510198-10414-1-git-send-email-peda@axentia.se> (raw)
In-Reply-To: <8a1d806c-1626-0558-855b-02d7396baae4@axentia.se>
The error handling is mixed up. mux_chip_alloc() doesn't return an error
pointer (just NULL on failure), so check for NULL instead of using IS_ERR.
devm_mux_chip_alloc is documented to return NULL on failure, so fix that
as well.
All users of devm_mux_chip_alloc() are coded according to documentation.
Fixes: a11c524a6b90 ("mux: minimal mux subsystem and gpio-based mux controller")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Peter Rosin <peda@axentia.se>
---
drivers/mux/mux-core.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/mux/mux-core.c b/drivers/mux/mux-core.c
index 900b88526f97..66a8bccfc3d7 100644
--- a/drivers/mux/mux-core.c
+++ b/drivers/mux/mux-core.c
@@ -166,12 +166,12 @@ struct mux_chip *devm_mux_chip_alloc(struct device *dev,
ptr = devres_alloc(devm_mux_chip_release, sizeof(*ptr), GFP_KERNEL);
if (!ptr)
- return ERR_PTR(-ENOMEM);
+ return NULL;
mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv);
- if (IS_ERR(mux_chip)) {
+ if (!mux_chip) {
devres_free(ptr);
- return mux_chip;
+ return NULL;
}
*ptr = mux_chip;
--
2.1.4
next prev parent reply other threads:[~2017-03-14 16:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 7:56 [PATCH] mux: checking for IS_ERR() instead of NULL or vice versa Dan Carpenter
2017-03-14 16:47 ` Peter Rosin
2017-03-14 16:49 ` Peter Rosin [this message]
2017-03-14 18:16 ` [PATCH] mux: core: fix error handling in devm_mux_chip_alloc Dan Carpenter
2017-03-15 10:01 ` 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=1489510198-10414-1-git-send-email-peda@axentia.se \
--to=peda@axentia.se \
--cc=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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®