Whamcloud - gitweb
LU-4423 obdclass: fix return value check in capa_hmac() 81/8681/3
authorOleg Drokin <oleg.drokin@intel.com>
Tue, 31 Dec 2013 01:38:49 +0000 (20:38 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 22 Feb 2014 08:06:48 +0000 (08:06 +0000)
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: Oleg Drokin <oleg.drokin@intel.com>
Change-Id: I4889387752d1eb5400649cd5f4da172d64c054e2
Reviewed-on: http://review.whamcloud.com/8681
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/obdclass/capa.c

index 5f5bc1b..29c40c1 100644 (file)
@@ -258,10 +258,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);
         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");
                 CERROR("crypto_alloc_tfm failed, check whether your kernel"
                        "has crypto support!\n");
-                return -ENOMEM;
+                return PTR_ERR(tfm);
         }
         keylen = alg->ha_keylen;
 
         }
         keylen = alg->ha_keylen;