From cd9de7ee61ff4b86b5b8ce08bff4d4bec7efed75 Mon Sep 17 00:00:00 2001 From: Alexander Leidinger Date: Sun, 5 Feb 2006 17:33:18 +0000 Subject: [PATCH] A pointer was checked for NULL after dereferencing it. The check is not needed here, except there's a bug which results in detaching the device twice. Move the NULL pointer check to the beginning of the function and convert it into a KASSERT. CID: 420 Found with: Coverity Prevent(tm) Discussed with: ariff MFC after: 5 days --- sys/dev/sound/pci/csapcm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sys/dev/sound/pci/csapcm.c b/sys/dev/sound/pci/csapcm.c index 2850c29cff2..2908d38eb75 100644 --- a/sys/dev/sound/pci/csapcm.c +++ b/sys/dev/sound/pci/csapcm.c @@ -722,6 +722,8 @@ csa_releaseres(struct csa_info *csa, device_t dev) { csa_res *resp; + KASSERT(csa != NULL, ("called with bogus resource structure")); + resp = &csa->res; if (resp->irq != NULL) { if (csa->ih) @@ -741,10 +743,8 @@ csa_releaseres(struct csa_info *csa, device_t dev) bus_dma_tag_destroy(csa->parent_dmat); csa->parent_dmat = NULL; } - if (csa != NULL) { - free(csa, M_DEVBUF); - csa = NULL; - } + + free(csa, M_DEVBUF); } static int