[PATCH] scsi: sym53c8xx_2: hipd: clean up error path in sym_alloc_ccb()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In sym_alloc_ccb(), if sym_calloc_dma() call fails, the code tries to call
sym_mfree_dma() on the cp local variable which is still NULL at this point.
Get rid of the meaningless code under the out_free label and, while at it,
get rid of the useless cp variable initializer...

Found by Linux Verification Center (linuxtesting.org) with the Svace static
analysis tool.

Signed-off-by: Sergey Shtylyov <s.shtylyov@xxxxxx>

---
The patch is against the for-next branch of Martin Petersen's scsi.git repo.

 drivers/scsi/sym53c8xx_2/sym_hipd.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Index: scsi/drivers/scsi/sym53c8xx_2/sym_hipd.c
===================================================================
--- scsi.orig/drivers/scsi/sym53c8xx_2/sym_hipd.c
+++ scsi/drivers/scsi/sym53c8xx_2/sym_hipd.c
@@ -4862,7 +4862,7 @@ void sym_free_ccb (struct sym_hcb *np, s
  */
 static struct sym_ccb *sym_alloc_ccb(struct sym_hcb *np)
 {
-	struct sym_ccb *cp = NULL;
+	struct sym_ccb *cp;
 	int hcode;
 
 	/*
@@ -4877,7 +4877,7 @@ static struct sym_ccb *sym_alloc_ccb(str
 	 */
 	cp = sym_calloc_dma(sizeof(struct sym_ccb), "CCB");
 	if (!cp)
-		goto out_free;
+		return NULL;
 
 	/*
 	 *  Count it.
@@ -4919,10 +4919,6 @@ static struct sym_ccb *sym_alloc_ccb(str
 	sym_insque_head(&cp->link2_ccbq, &np->dummy_ccbq);
 #endif
 	return cp;
-out_free:
-	if (cp)
-		sym_mfree_dma(cp, sizeof(*cp), "CCB");
-	return NULL;
 }
 
 /*




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux