goto err;
 
        drbg->Vbuf = kmalloc(drbg_statelen(drbg) + ret, GFP_KERNEL);
-       if (!drbg->Vbuf)
+       if (!drbg->Vbuf) {
+               ret = -ENOMEM;
                goto fini;
+       }
        drbg->V = PTR_ALIGN(drbg->Vbuf, ret + 1);
        drbg->Cbuf = kmalloc(drbg_statelen(drbg) + ret, GFP_KERNEL);
-       if (!drbg->Cbuf)
+       if (!drbg->Cbuf) {
+               ret = -ENOMEM;
                goto fini;
+       }
        drbg->C = PTR_ALIGN(drbg->Cbuf, ret + 1);
        /* scratchpad is only generated for CTR and Hash */
        if (drbg->core->flags & DRBG_HMAC)
 
        if (0 < sb_size) {
                drbg->scratchpadbuf = kzalloc(sb_size + ret, GFP_KERNEL);
-               if (!drbg->scratchpadbuf)
+               if (!drbg->scratchpadbuf) {
+                       ret = -ENOMEM;
                        goto fini;
+               }
                drbg->scratchpad = PTR_ALIGN(drbg->scratchpadbuf, ret + 1);
        }
 
 {
        unsigned int i = 0; /* pointer to drbg_algs */
        unsigned int j = 0; /* pointer to drbg_cores */
-       int ret = -EFAULT;
+       int ret;
 
        ret = drbg_healthcheck_sanity();
        if (ret)
                pr_info("DRBG: Cannot register all DRBG types"
                        "(slots needed: %zu, slots available: %zu)\n",
                        ARRAY_SIZE(drbg_cores) * 2, ARRAY_SIZE(drbg_algs));
-               return ret;
+               return -EFAULT;
        }
 
        /*