Skip to contentSkip to conversation

lpfc: potential leak in lpfc_sli_hbqbuf_fill_hbqs

PATCH In review Florin Malita 3 participants 3 messages Jul 19, 2007

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

PATCH 1/1 lpfc: potential leak in lpfc_sli_hbqbuf_fill_hbqs

If lpfc_hbq_alloc() fails, an hbq_buffer is leaked. Found by Coverity (1775).

---

drivers/scsi/lpfc/lpfc_sli.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_sli.c +0 -0
index f4d5a6b..fe16b0c 100644
@@ -622,8 +622,10 @@ lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, uint32_t hbqno, uint32_t count)
			return 1;
		hbq_buffer->dbuf.virt = lpfc_hbq_alloc(phba, MEM_PRI,
							&hbq_buffer->dbuf.phys);
-		if (hbq_buffer->dbuf.virt == NULL)
+		if (hbq_buffer->dbuf.virt == NULL) {
+			kfree(hbq_buffer);
			return 1;
+		}
		hbq_buffer->tag = (i | (hbqno << 16));
		lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer);
		lpfc_hbq_defs[hbqno]->buffer_count++;
#1 lore raw

Florin,

Thanks for the effort to create this patch. Turns out we have already fixed this, and have it included in our 8.2.2 patch set, which we will be posting within the next week.

So James, don't pick this patch up, take the larger patch set instead.

Thanks.

-- james s

Quoted 27 lines · Florin Malita

If lpfc_hbq_alloc() fails, an hbq_buffer is leaked. Found by Coverity (1775).

---

drivers/scsi/lpfc/lpfc_sli.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/lpfc/lpfc_sli.c +3 -1
index f4d5a6b..fe16b0c 100644
@@ -622,8 +622,10 @@ lpfc_sli_hbqbuf_fill_hbqs(struct lpfc_hba *phba, 
 uint32_t hbqno, uint32_t count)
            return 1;
        hbq_buffer->dbuf.virt = lpfc_hbq_alloc(phba, MEM_PRI,
                            &hbq_buffer->dbuf.phys);
-        if (hbq_buffer->dbuf.virt == NULL)
+        if (hbq_buffer->dbuf.virt == NULL) {
+            kfree(hbq_buffer);
            return 1;
+        }
        hbq_buffer->tag = (i | (hbqno << 16));
        lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buffer);
        lpfc_hbq_defs[hbqno]->buffer_count++;
#2 lore raw
Quoted 5 lines · James Smart

Florin,

Thanks for the effort to create this patch. Turns out we have already fixed this, and have it included in our 8.2.2 patch set, which we will be posting within the next week.

The 2.6.23 merge window is estimated to close on Sunday (22 July) ...

Quoted 1 line

So James, don't pick this patch up, take the larger patch set instead.

OK, will wait.

James