summaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorWei Yongjun <weiyongjun1@huawei.com>2016-09-16 01:49:41 +0000
committerHerbert Xu <herbert@gondor.apana.org.au>2016-09-22 18:27:48 +0800
commitf7eca278a8f81e701848392b522f80078bf2589f (patch)
tree1c7a1a2ac982e875532e10a81294c1bebdff2295 /drivers/char
parent06435f3437599d01653d42670c604d0b28a878e1 (diff)
downloadlinux-f7eca278a8f81e701848392b522f80078bf2589f.tar.gz
linux-f7eca278a8f81e701848392b522f80078bf2589f.tar.bz2
linux-f7eca278a8f81e701848392b522f80078bf2589f.zip
hwrng: amd - Fix return value check in mod_init()
In case of error, the function devm_kzalloc() or devm_ioport_map() return NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check should be replaced with NULL test. Fixes: 31b2a73c9c5f ("hwrng: amd - Migrate to managed API") Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/hw_random/amd-rng.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/char/hw_random/amd-rng.c b/drivers/char/hw_random/amd-rng.c
index 4dbc5aa23339..4a99ac756f08 100644
--- a/drivers/char/hw_random/amd-rng.c
+++ b/drivers/char/hw_random/amd-rng.c
@@ -149,8 +149,8 @@ found:
return -EIO;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
- if (IS_ERR(priv))
- return PTR_ERR(priv);
+ if (!priv)
+ return -ENOMEM;
if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET,
PMBASE_SIZE, DRV_NAME)) {
@@ -161,9 +161,9 @@ found:
priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET,
PMBASE_SIZE);
- if (IS_ERR(priv->iobase)) {
+ if (!priv->iobase) {
pr_err(DRV_NAME "Cannot map ioport\n");
- return PTR_ERR(priv->iobase);
+ return -ENOMEM;
}
amd_rng.priv = (unsigned long)priv;