Skip to content

Commit

Permalink
smb: use crypto_shash_digest() in symlink_hash()
Browse files Browse the repository at this point in the history
Simplify symlink_hash() by using crypto_shash_digest() instead of an
init+update+final sequence.  This should also improve performance.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Paulo Alcantara (SUSE) <pc@manguebit.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
  • Loading branch information
Eric Biggers authored and Steve French committed Oct 31, 2023
1 parent d328c09 commit 783fa2c
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions fs/smb/client/link.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,11 @@ symlink_hash(unsigned int link_len, const char *link_str, u8 *md5_hash)

rc = cifs_alloc_hash("md5", &md5);
if (rc)
goto symlink_hash_err;
return rc;

rc = crypto_shash_init(md5);
if (rc) {
cifs_dbg(VFS, "%s: Could not init md5 shash\n", __func__);
goto symlink_hash_err;
}
rc = crypto_shash_update(md5, link_str, link_len);
if (rc) {
cifs_dbg(VFS, "%s: Could not update with link_str\n", __func__);
goto symlink_hash_err;
}
rc = crypto_shash_final(md5, md5_hash);
rc = crypto_shash_digest(md5, link_str, link_len, md5_hash);
if (rc)
cifs_dbg(VFS, "%s: Could not generate md5 hash\n", __func__);

symlink_hash_err:
cifs_free_hash(&md5);
return rc;
}
Expand Down

0 comments on commit 783fa2c

Please sign in to comment.