From 3b1389f768e349d24c639026695f73c07392ddc4 Mon Sep 17 00:00:00 2001 From: "Thordur I. Bjornsson" Date: Tue, 8 Jun 2010 07:36:37 +0000 Subject: in viac3_crypto_setup(), if we fail to get a crypto driverid, free the softc before we return. While here, make the allocation code a bit prettier too. OK deraadt@ --- sys/arch/i386/i386/via.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'sys/arch/i386') diff --git a/sys/arch/i386/i386/via.c b/sys/arch/i386/i386/via.c index 16d3d5388c8..e904906052e 100644 --- a/sys/arch/i386/i386/via.c +++ b/sys/arch/i386/i386/via.c @@ -1,4 +1,4 @@ -/* $OpenBSD: via.c,v 1.20 2010/01/10 12:43:07 markus Exp $ */ +/* $OpenBSD: via.c,v 1.21 2010/06/08 07:36:36 thib Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -107,9 +107,9 @@ viac3_crypto_setup(void) { int algs[CRYPTO_ALGORITHM_MAX + 1]; - if ((vc3_sc = malloc(sizeof(*vc3_sc), M_DEVBUF, - M_NOWAIT|M_ZERO)) == NULL) - return; /* YYY bitch? */ + vc3_sc = malloc(sizeof(*vc3_sc), M_DEVBUF, M_NOWAIT|M_ZERO); + if (vc3_sc == NULL) + return; /* YYY bitch? */ bzero(algs, sizeof(algs)); algs[CRYPTO_AES_CBC] = CRYPTO_ALG_FLAG_SUPPORTED; @@ -121,8 +121,10 @@ viac3_crypto_setup(void) algs[CRYPTO_SHA2_512_HMAC] = CRYPTO_ALG_FLAG_SUPPORTED; vc3_sc->sc_cid = crypto_get_driverid(0); - if (vc3_sc->sc_cid < 0) + if (vc3_sc->sc_cid < 0) { + free(vc3_sc, M_DEVBUF); return; /* YYY bitch? */ + } crypto_register(vc3_sc->sc_cid, algs, viac3_crypto_newsession, viac3_crypto_freesession, viac3_crypto_process); -- cgit v1.2.3