aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeyslan G. Bem <geyslan@gmail.com>2013-11-18 14:42:57 -0500
committerJames Bottomley <JBottomley@Parallels.com>2013-12-19 10:39:04 -0500
commit0e7c60cb8cd7b0250b1cf40012e5015c90bb89db (patch)
tree5f12164138300488b75e3d69d96406691ae65c3e
parent6634ff7ca245bf2c0738cf21b545a35470ac7fe0 (diff)
[SCSI] be2iscsi: fix memory leak in error path
There are two memory leaks in cases 'ISCSI_NET_PARAM_VLAN_ID' and 'ISCSI_NET_PARAM_VLAN_PRIORITY' and also a potential junk pointer free if mgmt_get_if_info() returns error because if_info will be unset and it is stack allocated. Signed-off-by: Geyslan G. Bem <geyslan@gmail.com> Cc: Jayamohan Kallickal <jayamohan.kallickal@emulex.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r--drivers/scsi/be2iscsi/be_iscsi.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/scsi/be2iscsi/be_iscsi.c b/drivers/scsi/be2iscsi/be_iscsi.c
index ffadbee0b4d9..889066d9d6fb 100644
--- a/drivers/scsi/be2iscsi/be_iscsi.c
+++ b/drivers/scsi/be2iscsi/be_iscsi.c
@@ -541,10 +541,8 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
541 ip_type = BE2_IPV6; 541 ip_type = BE2_IPV6;
542 542
543 len = mgmt_get_if_info(phba, ip_type, &if_info); 543 len = mgmt_get_if_info(phba, ip_type, &if_info);
544 if (len) { 544 if (len)
545 kfree(if_info);
546 return len; 545 return len;
547 }
548 546
549 switch (param) { 547 switch (param) {
550 case ISCSI_NET_PARAM_IPV4_ADDR: 548 case ISCSI_NET_PARAM_IPV4_ADDR:
@@ -569,7 +567,7 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
569 break; 567 break;
570 case ISCSI_NET_PARAM_VLAN_ID: 568 case ISCSI_NET_PARAM_VLAN_ID:
571 if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) 569 if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE)
572 return -EINVAL; 570 len = -EINVAL;
573 else 571 else
574 len = sprintf(buf, "%d\n", 572 len = sprintf(buf, "%d\n",
575 (if_info->vlan_priority & 573 (if_info->vlan_priority &
@@ -577,7 +575,7 @@ static int be2iscsi_get_if_param(struct beiscsi_hba *phba,
577 break; 575 break;
578 case ISCSI_NET_PARAM_VLAN_PRIORITY: 576 case ISCSI_NET_PARAM_VLAN_PRIORITY:
579 if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE) 577 if (if_info->vlan_priority == BEISCSI_VLAN_DISABLE)
580 return -EINVAL; 578 len = -EINVAL;
581 else 579 else
582 len = sprintf(buf, "%d\n", 580 len = sprintf(buf, "%d\n",
583 ((if_info->vlan_priority >> 13) & 581 ((if_info->vlan_priority >> 13) &