aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2016-01-24 08:20:02 -0500
committerHerbert Xu <herbert@gondor.apana.org.au>2016-01-27 07:36:13 -0500
commit1edb82d2021c7bae96509c03c4c5ef789f1e09a3 (patch)
treef384a6747d7a68902b8691f530dff0c676b5dcd0
parent69110e3cedbb8aad1c70d91ed58a9f4f0ed9eec6 (diff)
nfsd: Use shash
This patch replaces uses of the long obsolete hash interface with shash. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--fs/nfsd/nfs4recover.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index dc8ebecf5618..195fe2668207 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -32,10 +32,10 @@
32* 32*
33*/ 33*/
34 34
35#include <crypto/hash.h>
35#include <linux/file.h> 36#include <linux/file.h>
36#include <linux/slab.h> 37#include <linux/slab.h>
37#include <linux/namei.h> 38#include <linux/namei.h>
38#include <linux/crypto.h>
39#include <linux/sched.h> 39#include <linux/sched.h>
40#include <linux/fs.h> 40#include <linux/fs.h>
41#include <linux/module.h> 41#include <linux/module.h>
@@ -104,29 +104,35 @@ static int
104nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname) 104nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
105{ 105{
106 struct xdr_netobj cksum; 106 struct xdr_netobj cksum;
107 struct hash_desc desc; 107 struct crypto_shash *tfm;
108 struct scatterlist sg;
109 int status; 108 int status;
110 109
111 dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n", 110 dprintk("NFSD: nfs4_make_rec_clidname for %.*s\n",
112 clname->len, clname->data); 111 clname->len, clname->data);
113 desc.flags = CRYPTO_TFM_REQ_MAY_SLEEP; 112 tfm = crypto_alloc_shash("md5", 0, 0);
114 desc.tfm = crypto_alloc_hash("md5", 0, CRYPTO_ALG_ASYNC); 113 if (IS_ERR(tfm)) {
115 if (IS_ERR(desc.tfm)) { 114 status = PTR_ERR(tfm);
116 status = PTR_ERR(desc.tfm);
117 goto out_no_tfm; 115 goto out_no_tfm;
118 } 116 }
119 117
120 cksum.len = crypto_hash_digestsize(desc.tfm); 118 cksum.len = crypto_shash_digestsize(tfm);
121 cksum.data = kmalloc(cksum.len, GFP_KERNEL); 119 cksum.data = kmalloc(cksum.len, GFP_KERNEL);
122 if (cksum.data == NULL) { 120 if (cksum.data == NULL) {
123 status = -ENOMEM; 121 status = -ENOMEM;
124 goto out; 122 goto out;
125 } 123 }
126 124
127 sg_init_one(&sg, clname->data, clname->len); 125 {
126 SHASH_DESC_ON_STACK(desc, tfm);
127
128 desc->tfm = tfm;
129 desc->flags = CRYPTO_TFM_REQ_MAY_SLEEP;
130
131 status = crypto_shash_digest(desc, clname->data, clname->len,
132 cksum.data);
133 shash_desc_zero(desc);
134 }
128 135
129 status = crypto_hash_digest(&desc, &sg, sg.length, cksum.data);
130 if (status) 136 if (status)
131 goto out; 137 goto out;
132 138
@@ -135,7 +141,7 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
135 status = 0; 141 status = 0;
136out: 142out:
137 kfree(cksum.data); 143 kfree(cksum.data);
138 crypto_free_hash(desc.tfm); 144 crypto_free_shash(tfm);
139out_no_tfm: 145out_no_tfm:
140 return status; 146 return status;
141} 147}