From: Dan Carpenter <dan.carpenter@oracle.com>
To: Peter Rosin <peda@axentia.se>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] mux: checking for IS_ERR() instead of NULL or vice versa
Date: Tue, 14 Mar 2017 07:56:32 +0000 [thread overview]
Message-ID: <20170314075243.GA6169@mwanda> (raw)
This error handling is mixed up. mux_chip_alloc() doesn't return error
pointers but devm_mux_chip_alloc() does.
Fixes: 4f5078327db1 ("mux: minimal mux subsystem and gpio-based mux controller")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/mux/mux-core.c b/drivers/mux/mux-core.c
index 46088a0f9677..de678520a329 100644
--- a/drivers/mux/mux-core.c
+++ b/drivers/mux/mux-core.c
@@ -167,9 +167,9 @@ struct mux_chip *devm_mux_chip_alloc(struct device *dev,
return ERR_PTR(-ENOMEM);
mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv);
- if (IS_ERR(mux_chip)) {
+ if (!mux_chip) {
devres_free(ptr);
- return mux_chip;
+ return ERR_PTR(-ENOMEM);
}
*ptr = mux_chip;
diff --git a/drivers/mux/mux-gpio.c b/drivers/mux/mux-gpio.c
index 04c6e548ecdc..d0596a3c2f79 100644
--- a/drivers/mux/mux-gpio.c
+++ b/drivers/mux/mux-gpio.c
@@ -63,8 +63,8 @@ static int mux_gpio_probe(struct platform_device *pdev)
mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*mux_gpio) +
pins * sizeof(*mux_gpio->val));
- if (!mux_chip)
- return -ENOMEM;
+ if (IS_ERR(mux_chip))
+ return PTR_ERR(mux_chip);
mux_gpio = mux_chip_priv(mux_chip);
mux_gpio->val = (int *)(mux_gpio + 1);
diff --git a/drivers/mux/mux-adg792a.c b/drivers/mux/mux-adg792a.c
index d58971641fdc..8972f4f6c655 100644
--- a/drivers/mux/mux-adg792a.c
+++ b/drivers/mux/mux-adg792a.c
@@ -65,8 +65,8 @@ static int adg792a_probe(struct i2c_client *i2c,
return -EINVAL;
mux_chip = devm_mux_chip_alloc(dev, cells ? 3 : 1, 0);
- if (!mux_chip)
- return -ENOMEM;
+ if (IS_ERR(mux_chip))
+ return PTR_ERR(mux_chip);
mux_chip->ops = &adg792a_ops;
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Peter Rosin <peda@axentia.se>
Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] mux: checking for IS_ERR() instead of NULL or vice versa
Date: Tue, 14 Mar 2017 10:56:32 +0300 [thread overview]
Message-ID: <20170314075243.GA6169@mwanda> (raw)
This error handling is mixed up. mux_chip_alloc() doesn't return error
pointers but devm_mux_chip_alloc() does.
Fixes: 4f5078327db1 ("mux: minimal mux subsystem and gpio-based mux controller")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/mux/mux-core.c b/drivers/mux/mux-core.c
index 46088a0f9677..de678520a329 100644
--- a/drivers/mux/mux-core.c
+++ b/drivers/mux/mux-core.c
@@ -167,9 +167,9 @@ struct mux_chip *devm_mux_chip_alloc(struct device *dev,
return ERR_PTR(-ENOMEM);
mux_chip = mux_chip_alloc(dev, controllers, sizeof_priv);
- if (IS_ERR(mux_chip)) {
+ if (!mux_chip) {
devres_free(ptr);
- return mux_chip;
+ return ERR_PTR(-ENOMEM);
}
*ptr = mux_chip;
diff --git a/drivers/mux/mux-gpio.c b/drivers/mux/mux-gpio.c
index 04c6e548ecdc..d0596a3c2f79 100644
--- a/drivers/mux/mux-gpio.c
+++ b/drivers/mux/mux-gpio.c
@@ -63,8 +63,8 @@ static int mux_gpio_probe(struct platform_device *pdev)
mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*mux_gpio) +
pins * sizeof(*mux_gpio->val));
- if (!mux_chip)
- return -ENOMEM;
+ if (IS_ERR(mux_chip))
+ return PTR_ERR(mux_chip);
mux_gpio = mux_chip_priv(mux_chip);
mux_gpio->val = (int *)(mux_gpio + 1);
diff --git a/drivers/mux/mux-adg792a.c b/drivers/mux/mux-adg792a.c
index d58971641fdc..8972f4f6c655 100644
--- a/drivers/mux/mux-adg792a.c
+++ b/drivers/mux/mux-adg792a.c
@@ -65,8 +65,8 @@ static int adg792a_probe(struct i2c_client *i2c,
return -EINVAL;
mux_chip = devm_mux_chip_alloc(dev, cells ? 3 : 1, 0);
- if (!mux_chip)
- return -ENOMEM;
+ if (IS_ERR(mux_chip))
+ return PTR_ERR(mux_chip);
mux_chip->ops = &adg792a_ops;
next reply other threads:[~2017-03-14 7:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-14 7:56 Dan Carpenter [this message]
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:47 ` Peter Rosin
2017-03-14 16:49 ` [PATCH] mux: core: fix error handling in devm_mux_chip_alloc Peter Rosin
2017-03-14 16:49 ` Peter Rosin
2017-03-14 18:16 ` Dan Carpenter
2017-03-14 18:16 ` Dan Carpenter
2017-03-15 10:01 ` Peter Rosin
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=20170314075243.GA6169@mwanda \
--to=dan.carpenter@oracle.com \
--cc=kernel-janitors@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.