crypto: atmel - fix checks of error code returned by devm_ioremap_resource()
authorVladimir Zapolskiy <vz@mleia.com>
Sun, 6 Mar 2016 01:21:52 +0000 (03:21 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 11 Mar 2016 13:19:19 +0000 (21:19 +0800)
The change fixes potential oops while accessing iomem on invalid
address, if devm_ioremap_resource() fails due to some reason.

The devm_ioremap_resource() function returns ERR_PTR() and never
returns NULL, which makes useless a following check for NULL.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Fixes: b0e8b3417a62 ("crypto: atmel - use devm_xxx() managed function")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/atmel-aes.c
drivers/crypto/atmel-sha.c
drivers/crypto/atmel-tdes.c

index 949af89cdac3de55c0c03c9a78d0e4ad1ae268cb..93474f8babfc3b085901b2b97bb3c235a099118d 100644 (file)
@@ -2079,9 +2079,9 @@ static int atmel_aes_probe(struct platform_device *pdev)
        }
 
        aes_dd->io_base = devm_ioremap_resource(&pdev->dev, aes_res);
-       if (!aes_dd->io_base) {
+       if (IS_ERR(aes_dd->io_base)) {
                dev_err(dev, "can't ioremap\n");
-               err = -ENOMEM;
+               err = PTR_ERR(aes_dd->io_base);
                goto res_err;
        }
 
index 7b93586154a788a6d81905d216313ca1d1d9d03c..4b2dd95782bfc175a1d9c773689b6f06e3a87f28 100644 (file)
@@ -1486,9 +1486,9 @@ static int atmel_sha_probe(struct platform_device *pdev)
        }
 
        sha_dd->io_base = devm_ioremap_resource(&pdev->dev, sha_res);
-       if (!sha_dd->io_base) {
+       if (IS_ERR(sha_dd->io_base)) {
                dev_err(dev, "can't ioremap\n");
-               err = -ENOMEM;
+               err = PTR_ERR(sha_dd->io_base);
                goto res_err;
        }
 
index 2c7a628d0375fd43d80f82084b38eed009a8f032..bf467d7be35cfe2d94fccdbb884716c948017bd6 100644 (file)
@@ -1417,9 +1417,9 @@ static int atmel_tdes_probe(struct platform_device *pdev)
        }
 
        tdes_dd->io_base = devm_ioremap_resource(&pdev->dev, tdes_res);
-       if (!tdes_dd->io_base) {
+       if (IS_ERR(tdes_dd->io_base)) {
                dev_err(dev, "can't ioremap\n");
-               err = -ENOMEM;
+               err = PTR_ERR(tdes_dd->io_base);
                goto res_err;
        }