Merge tag 'drm-fixes-for-v4.17-rc1' of git://people.freedesktop.org/~airlied/linux
[platform/kernel/linux-rpi.git] / fs / cifs / smbencrypt.c
index c12bffe..a0b80ac 100644 (file)
@@ -121,25 +121,12 @@ int
 mdfour(unsigned char *md4_hash, unsigned char *link_str, int link_len)
 {
        int rc;
-       unsigned int size;
-       struct crypto_shash *md4;
-       struct sdesc *sdescmd4;
-
-       md4 = crypto_alloc_shash("md4", 0, 0);
-       if (IS_ERR(md4)) {
-               rc = PTR_ERR(md4);
-               cifs_dbg(VFS, "%s: Crypto md4 allocation error %d\n",
-                        __func__, rc);
-               return rc;
-       }
-       size = sizeof(struct shash_desc) + crypto_shash_descsize(md4);
-       sdescmd4 = kmalloc(size, GFP_KERNEL);
-       if (!sdescmd4) {
-               rc = -ENOMEM;
+       struct crypto_shash *md4 = NULL;
+       struct sdesc *sdescmd4 = NULL;
+
+       rc = cifs_alloc_hash("md4", &md4, &sdescmd4);
+       if (rc)
                goto mdfour_err;
-       }
-       sdescmd4->shash.tfm = md4;
-       sdescmd4->shash.flags = 0x0;
 
        rc = crypto_shash_init(&sdescmd4->shash);
        if (rc) {
@@ -156,9 +143,7 @@ mdfour(unsigned char *md4_hash, unsigned char *link_str, int link_len)
                cifs_dbg(VFS, "%s: Could not generate md4 hash\n", __func__);
 
 mdfour_err:
-       crypto_free_shash(md4);
-       kfree(sdescmd4);
-
+       cifs_free_hash(&md4, &sdescmd4);
        return rc;
 }