[PATCH] nfsd: Fix cld_net->cn_tfm initialization

From: Scott Mayhew
Date: Tue Nov 12 2019 - 10:10:00 EST


Don't assign an error pointer to cn->cn_tfm, otherwise
an oops will occur in nfsd4_remove_cld_pipe().

Fixes: 6ee95d1c8991 ("nfsd: add support for upcall version 2")
Reported-by: Jamie Heilman <jamie@xxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Scott Mayhew <smayhew@xxxxxxxxxx>
---
fs/nfsd/nfs4recover.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index cdc75ad4438b..af07d0f55fe3 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -1578,6 +1578,7 @@ nfsd4_cld_tracking_init(struct net *net)
=09struct nfsd_net *nn =3D net_generic(net, nfsd_net_id);
=09bool running;
=09int retries =3D 10;
+=09struct crypto_shash *tfm;
=20
=09status =3D nfs4_cld_state_init(net);
=09if (status)
@@ -1586,11 +1587,13 @@ nfsd4_cld_tracking_init(struct net *net)
=09status =3D __nfsd4_init_cld_pipe(net);
=09if (status)
=09=09goto err_shutdown;
+=09tfm =3D crypto_alloc_shash("sha256", 0, 0);
=09nn->cld_net->cn_tfm =3D crypto_alloc_shash("sha256", 0, 0);
-=09if (IS_ERR(nn->cld_net->cn_tfm)) {
-=09=09status =3D PTR_ERR(nn->cld_net->cn_tfm);
+=09if (IS_ERR(tfm)) {
+=09=09status =3D PTR_ERR(tfm);
=09=09goto err_remove;
=09}
+=09nn->cld_net->cn_tfm =3D tfm;
=20
=09/*
=09 * rpc pipe upcalls take 30 seconds to time out, so we don't want to
--=20
2.17.2


--nFreZHaLTZJo0R7j--