1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-17 15:27:36 +00:00

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)
This commit is contained in:
Andrew Rybchenko 2015-02-21 06:27:45 +00:00
parent 4e41fb10cb
commit 1924cbe5d3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=279097

View File

@ -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;