Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 573dbd95 authored by Jesper Juhl's avatar Jesper Juhl Committed by David S. Miller
Browse files

[CRYPTO]: crypto_free_tfm() callers no longer need to check for NULL



Since the patch to add a NULL short-circuit to crypto_free_tfm() went in,
there's no longer any need for callers of that function to check for NULL.
This patch removes the redundant NULL checks and also a few similar checks
for NULL before calls to kfree() that I ran into while doing the
crypto_free_tfm bits.

I've succesfuly compile tested this patch, and a kernel with the patch 
applied boots and runs just fine.

When I posted the patch to LKML (and other lists/people on Cc) it drew the
following comments :

 J. Bruce Fields commented
  "I've no problem with the auth_gss or nfsv4 bits.--b."

 Sridhar Samudrala said
  "sctp change looks fine."

 Herbert Xu signed off on the patch.

So, I guess this is ready to be dropped into -mm and eventually mainline.

Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5170dbeb
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2403,7 +2403,6 @@ void stop_airo_card( struct net_device *dev, int freeres )
		}
        }
#ifdef MICSUPPORT
	if (ai->tfm)
	crypto_free_tfm(ai->tfm);
#endif
	del_airo_dev( dev );
+1 −2
Original line number Diff line number Diff line
@@ -114,7 +114,6 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
	kfree(cksum.data);
	status = nfs_ok;
out:
	if (tfm)
	crypto_free_tfm(tfm);
	return status;
}
+6 −12
Original line number Diff line number Diff line
@@ -263,9 +263,7 @@ static int ah_init_state(struct xfrm_state *x)

error:
	if (ahp) {
		if (ahp->work_icv)
		kfree(ahp->work_icv);
		if (ahp->tfm)
		crypto_free_tfm(ahp->tfm);
		kfree(ahp);
	}
@@ -279,14 +277,10 @@ static void ah_destroy(struct xfrm_state *x)
	if (!ahp)
		return;

	if (ahp->work_icv) {
	kfree(ahp->work_icv);
	ahp->work_icv = NULL;
	}
	if (ahp->tfm) {
	crypto_free_tfm(ahp->tfm);
	ahp->tfm = NULL;
	}
	kfree(ahp);
}

+8 −16
Original line number Diff line number Diff line
@@ -343,22 +343,14 @@ static void esp_destroy(struct xfrm_state *x)
	if (!esp)
		return;

	if (esp->conf.tfm) {
	crypto_free_tfm(esp->conf.tfm);
	esp->conf.tfm = NULL;
	}
	if (esp->conf.ivec) {
	kfree(esp->conf.ivec);
	esp->conf.ivec = NULL;
	}
	if (esp->auth.tfm) {
	crypto_free_tfm(esp->auth.tfm);
	esp->auth.tfm = NULL;
	}
	if (esp->auth.work_icv) {
	kfree(esp->auth.work_icv);
	esp->auth.work_icv = NULL;
	}
	kfree(esp);
}

+1 −2
Original line number Diff line number Diff line
@@ -345,7 +345,6 @@ static void ipcomp_free_tfms(struct crypto_tfm **tfms)

	for_each_cpu(cpu) {
		struct crypto_tfm *tfm = *per_cpu_ptr(tfms, cpu);
		if (tfm)
		crypto_free_tfm(tfm);
	}
	free_percpu(tfms);
Loading