svn commit: r280561 - stable/10/sys/dev/sfxge/common
Andrew Rybchenko
arybchik at FreeBSD.org
Wed Mar 25 11:01:59 UTC 2015
Author: arybchik
Date: Wed Mar 25 11:01:58 2015
New Revision: 280561
URL: https://svnweb.freebsd.org/changeset/base/280561
Log:
MFC: 279097
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:
stable/10/sys/dev/sfxge/common/efx_filter.c
Directory Properties:
stable/10/ (props changed)
Modified: stable/10/sys/dev/sfxge/common/efx_filter.c
==============================================================================
--- stable/10/sys/dev/sfxge/common/efx_filter.c Wed Mar 25 11:01:03 2015 (r280560)
+++ stable/10/sys/dev/sfxge/common/efx_filter.c Wed Mar 25 11:01:58 2015 (r280561)
@@ -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;
More information about the svn-src-all
mailing list