Commit f7eca278 authored by Wei Yongjun's avatar Wei Yongjun Committed by Herbert Xu

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: 31b2a73c ("hwrng: amd - Migrate to managed API")
Signed-off-by: default avatarWei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 06435f34
...@@ -149,8 +149,8 @@ static int __init mod_init(void) ...@@ -149,8 +149,8 @@ static int __init mod_init(void)
return -EIO; return -EIO;
priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
if (IS_ERR(priv)) if (!priv)
return PTR_ERR(priv); return -ENOMEM;
if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET, if (!devm_request_region(&pdev->dev, pmbase + PMBASE_OFFSET,
PMBASE_SIZE, DRV_NAME)) { PMBASE_SIZE, DRV_NAME)) {
...@@ -161,9 +161,9 @@ static int __init mod_init(void) ...@@ -161,9 +161,9 @@ static int __init mod_init(void)
priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET, priv->iobase = devm_ioport_map(&pdev->dev, pmbase + PMBASE_OFFSET,
PMBASE_SIZE); PMBASE_SIZE);
if (IS_ERR(priv->iobase)) { if (!priv->iobase) {
pr_err(DRV_NAME "Cannot map ioport\n"); pr_err(DRV_NAME "Cannot map ioport\n");
return PTR_ERR(priv->iobase); return -ENOMEM;
} }
amd_rng.priv = (unsigned long)priv; amd_rng.priv = (unsigned long)priv;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment