Skip to contentSkip to conversation

megaraid_sas: missing curly braces in megasas_detach_one()

PATCH In review Dan Carpenter 2 participants 2 messages Nov 7, 2015 – Nov 10, 2015

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

PATCH 2/2 megaraid_sas: missing curly braces in megasas_detach_one()

The indenting indicates that there are supposed to be some curly braces here. Presumably it means we free something unintentionally leading to a use after free.

Fixes 3761cb4cf65e ('megaraid_sas: JBOD sequence number support')

---
Not tested.

drivers/scsi/megaraid/megaraid_sas_base.c +2 -1
index 829e9e9..91e200d 100644
@@ -5932,7 +5932,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
 						  fusion->max_map_sz,
 						  fusion->ld_map[i],
 						  fusion->ld_map_phys[i]);
-			if (fusion->ld_drv_map[i])
+			if (fusion->ld_drv_map[i]) {
 				free_pages((ulong)fusion->ld_drv_map[i],
 					fusion->drv_map_pages);
 				if (fusion->pd_seq_sync)
@@ -5940,6 +5940,7 @@ static void megasas_detach_one(struct pci_dev *pdev)
 						pd_seq_map_sz,
 						fusion->pd_seq_sync[i],
 						fusion->pd_seq_phys[i]);
+			}
 		}
 		free_pages((ulong)instance->ctrl_context,
 			instance->ctrl_context_pages);
#1 lore raw
Quoted 11 lines

-----Original Message-----
From: Dan Carpenter [mailto:[email protected]]
Sent: Saturday, November 07, 2015 9:47 PM
To: Kashyap Desai; Sumit Saxena
Cc: Uday Lingala; James E.J. Bottomley; [email protected]; [email protected]; [email protected]
Subject: [patch 2/2] megaraid_sas: missing curly braces in megasas_detach_one()

The indenting indicates that there are supposed to be some curly braces here. Presumably it means we free something unintentionally leading to

a

Quoted 1 line

use after free.

NACK. Indentation is wrong. We don't need to add braces. We will fix indentation and resend patch. Since this is not critical, let's ignore for now.

Quoted 30 lines
Fixes 3761cb4cf65e ('megaraid_sas: JBOD sequence number support')

---
Not tested.

drivers/scsi/megaraid/megaraid_sas_base.c +1 -1
index 829e9e9..91e200d 100644
@@ -5932,7 +5932,7 @@ static void megasas_detach_one(struct pci_dev
 *pdev)
 						  fusion->max_map_sz,
 						  fusion->ld_map[i],
 						  fusion->ld_map_phys[i]);
-			if (fusion->ld_drv_map[i])
+			if (fusion->ld_drv_map[i]) {
 				free_pages((ulong)fusion->ld_drv_map[i],
 					fusion->drv_map_pages);
drivers/scsi/megaraid/megaraid_sas_base.c +1 -0
 				if (fusion->pd_seq_sync)
@@ -5940,6 +5940,7 @@ static void megasas_detach_one(struct pci_dev
 *pdev)
 						pd_seq_map_sz,
 						fusion->pd_seq_sync[i],
 						fusion->pd_seq_phys[i]);
+			}
 		}
 		free_pages((ulong)instance->ctrl_context,

instance->ctrl_context_pages);