Skip to contentSkip to conversation

qla4xxx: don't free NULL dma pool

PATCH In review Dan Carpenter 2 participants 2 messages Jan 30, 2013

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qla4xxx: don't free NULL dma pool

The error path calls dma_pool_free() on this path but "chap_table" is NULL and "chap_dma" is uninitialized. It's cleaner to just return directly.

drivers/scsi/qla4xxx/ql4_mbx.c +2 -4
index 1c57c22..887e409 100644
@@ -1404,10 +1404,8 @@ int qla4xxx_get_chap(struct scsi_qla_host *ha, char *username, char *password,
 	dma_addr_t chap_dma;
 
 	chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
-	if (chap_table = NULL) {
-		ret = -ENOMEM;
-		goto exit_get_chap;
-	}
+	if (chap_table = NULL)
+		return -ENOMEM;
 
 	chap_size = sizeof(struct ql4_chap_table);
 	memset(chap_table, 0, chap_size);
Acked-by on v1 1/1
#1 lore raw

-----Original Message-----
From: Dan Carpenter <[email protected]>
Date: Wednesday 30 January 2013 12:37 PM
To: Ravi Anand <[email protected]>
Cc: Vikas <[email protected]>, Dept-Eng iSCSI Driver <[email protected]>, "James E.J. Bottomley" <[email protected]>, scsi <[email protected]>, "[email protected]" <[email protected]>
Subject: [patch] [SCSI] qla4xxx: don't free NULL dma pool

Quoted 24 lines

The error path calls dma_pool_free() on this path but "chap_table" is NULL and "chap_dma" is uninitialized. It's cleaner to just return directly.

drivers/scsi/qla4xxx/ql4_mbx.c +2 -4
index 1c57c22..887e409 100644
@@ -1404,10 +1404,8 @@ int qla4xxx_get_chap(struct scsi_qla_host *ha,
 char *username, char *password,
      dma_addr_t chap_dma;
 
      chap_table = dma_pool_alloc(ha->chap_dma_pool, GFP_KERNEL, &chap_dma);
-      if (chap_table = NULL) {
-              ret = -ENOMEM;
-              goto exit_get_chap;
-      }
+      if (chap_table = NULL)
+              return -ENOMEM;
 
      chap_size = sizeof(struct ql4_chap_table);
Quoted 1 line
      memset(chap_table, 0, chap_size);

Thanks for a fix.

________________________________

This message and any attached documents contain information from QLogic Corporation or its wholly-owned subsidiaries that may be confidential. If you are not the intended recipient, you may not read, copy, distribute, or use this information. If you have received this transmission in error, please notify the sender immediately by reply e-mail and then delete this message.