[PATCH v2] 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 | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index cdc75ad4438b..d1bc56b2e861 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,12 @@ nfsd4_cld_tracking_init(struct net *net)
=09status =3D __nfsd4_init_cld_pipe(net);
=09if (status)
=09=09goto err_shutdown;
-=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);
+=09tfm =3D crypto_alloc_shash("sha256", 0, 0);
+=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


--0lnxQi9hkpPO77W3--