staging: lustre: fix return value check in capa_hmac()
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Fri, 20 Dec 2013 03:41:11 +0000 (11:41 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 20 Dec 2013 19:45:09 +0000 (11:45 -0800)
In case of error, the function crypto_alloc_hash() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/obdclass/capa.c

index 86deee5e70d1e7ead9ee5896b6a4fce674dab7f9..be1c613383a6b1206197a005702cbc2d43e734c4 100644 (file)
@@ -272,10 +272,10 @@ int capa_hmac(__u8 *hmac, struct lustre_capa *capa, __u8 *key)
        alg = &capa_hmac_algs[capa_alg(capa)];
 
        tfm = crypto_alloc_hash(alg->ha_name, 0, 0);
-       if (!tfm) {
+       if (IS_ERR(tfm)) {
                CERROR("crypto_alloc_tfm failed, check whether your kernel"
                       "has crypto support!\n");
-               return -ENOMEM;
+               return PTR_ERR(tfm);
        }
        keylen = alg->ha_keylen;