Date: Sat, 21 Feb 2015 06:27:46 +0000 (UTC) From: Andrew Rybchenko <arybchik@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279097 - head/sys/dev/sfxge/common Message-ID: <201502210627.t1L6RkAY053190@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: arybchik Date: Sat Feb 21 06:27:45 2015 New Revision: 279097 URL: https://svnweb.freebsd.org/changeset/base/279097 Log: sfxge: check allocations are non-NULL before freeing them Caught when efx_filter_init() failed and called efx_filter_fini() in the teardown path. Submitted by: Andrew Lee <alee at solarflare.com> Sponsored by: Solarflare Communications, Inc. Approved by: gnn (mentor) Modified: head/sys/dev/sfxge/common/efx_filter.c Modified: head/sys/dev/sfxge/common/efx_filter.c ============================================================================== --- head/sys/dev/sfxge/common/efx_filter.c Sat Feb 21 06:27:16 2015 (r279096) +++ head/sys/dev/sfxge/common/efx_filter.c Sat Feb 21 06:27:45 2015 (r279097) @@ -721,7 +721,7 @@ efx_filter_init( eftp->eft_spec); if (!eftp->eft_spec) { rc = ENOMEM; - goto fail2; + goto fail3; } memset(eftp->eft_spec, 0, eftp->eft_size * sizeof(*eftp->eft_spec)); } @@ -729,6 +729,9 @@ efx_filter_init( return (0); +fail3: + EFSYS_PROBE(fail3); + fail2: EFSYS_PROBE(fail2); efx_filter_fini(enp); @@ -755,12 +758,17 @@ efx_filter_fini( EFX_STATIC_ASSERT(sizeof(eftp->eft_bitmap[0]) == sizeof(uint32_t)); bitmap_size = (eftp->eft_size + (sizeof(uint32_t) * 8) - 1) / 8; - EFSYS_KMEM_FREE(enp->en_esip, bitmap_size, eftp->eft_bitmap); - eftp->eft_bitmap = NULL; + if (eftp->eft_bitmap != NULL) { + EFSYS_KMEM_FREE(enp->en_esip, bitmap_size, + eftp->eft_bitmap); + eftp->eft_bitmap = NULL; + } - EFSYS_KMEM_FREE(enp->en_esip, eftp->eft_size * sizeof(*eftp->eft_spec), - eftp->eft_spec); - eftp->eft_spec = NULL; + if (eftp->eft_spec != NULL) { + EFSYS_KMEM_FREE(enp->en_esip, eftp->eft_size * + sizeof(*eftp->eft_spec), eftp->eft_spec); + eftp->eft_spec = NULL; + } } enp->en_mod_flags &= ~EFX_MOD_FILTER;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502210627.t1L6RkAY053190>