From mboxrd@z Thu Jan 1 00:00:00 1970 From: Maurizio Lombardi Subject: [PATCH] be2iscsi: Fix memory leak in beiscsi_alloc_mem() Date: Thu, 1 Oct 2015 10:56:25 +0200 Message-ID: <1443689785-13712-1-git-send-email-mlombard@redhat.com> Return-path: Received: from mx1.redhat.com ([209.132.183.28]:33267 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752780AbbJAI41 (ORCPT ); Thu, 1 Oct 2015 04:56:27 -0400 Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: linux-scsi@vger.kernel.org Cc: jayamohan.kallickal@avagotech.com, minh.tran@avagotech.com, sony.john-n@avagotech.com, James.Bottomley@HansenPartnership.com In case of error, the memory allocated for phwi_ctrlr was not freed. Signed-off-by: Maurizio Lombardi --- drivers/scsi/be2iscsi/be_main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index 7a6dbfb..360aa88 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c @@ -2706,8 +2706,10 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) * phba->params.cxns_per_ctrl, GFP_KERNEL); - if (!phwi_ctrlr->wrb_context) + if (!phwi_ctrlr->wrb_context) { + kfree(phba->phwi_ctrlr); return -ENOMEM; + } phba->init_mem = kcalloc(SE_MEM_MAX, sizeof(*mem_descr), GFP_KERNEL); -- Maurizio Lombardi