Skip to contentSkip to conversation

memstick: memory leak on error in msb_ftl_scan()

PATCH In review Dan Carpenter 2 participants 3 messages Sep 29, 2012

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

PATCH 2/2 memstick: memory leak on error in msb_ftl_scan()

We need to free "overwrite_flags" before returning.

drivers/memstick/core/ms_block.c +3 -1
index a8e8915..1f9d5cf 100644
@@ -1408,8 +1408,10 @@ static int msb_ftl_scan(struct msb_data *msb)
 			msb_mark_block_used(msb, pba);
 			msb_erase_block(msb, pba);
 			continue;
-		} else if (error)
+		} else if (error) {
+			kfree(overwrite_flags);
 			return error;
+		}
 
 		lba = be16_to_cpu(extra.logical_address);
 		managment_flag = extra.management_flag;
maintainer Acked-by on v1 2/2
#1 lore raw
Quoted 10 lines · Dan Carpenter

We need to free "overwrite_flags" before returning.

drivers/memstick/core/ms_block.c +0 -0
index a8e8915..1f9d5cf 100644
@@ -1408,8 +1408,10 @@ static int msb_ftl_scan(struct msb_data *msb)
 			msb_mark_block_used(msb, pba);

drivers/memstick/core/ms_block.c static int msb_ftl_scan(struct msb_data *msb) · line 1417

Quoted 10 lines
drivers/memstick/core/ms_block.c +3 -1
 			msb_erase_block(msb, pba);
 			continue;
-		} else if (error)
+		} else if (error) {
+			kfree(overwrite_flags);
 			return error;
+		}
 
 		lba = be16_to_cpu(extra.logical_address);
 		managment_flag = extra.management_flag;

Indeed. I need to be more careful with this,
I'll do another review of the code, maybe I spot anything else.

Best regards,
Maxim Levitsky

maintainer
#2 lore raw
Quoted 19 lines · Maxim Levitsky
Quoted 18 lines · Dan Carpenter

We need to free "overwrite_flags" before returning.

drivers/memstick/core/ms_block.c +3 -1
index a8e8915..1f9d5cf 100644
@@ -1408,8 +1408,10 @@ static int msb_ftl_scan(struct msb_data *msb)
 			msb_mark_block_used(msb, pba);
 			msb_erase_block(msb, pba);
 			continue;
-		} else if (error)
+		} else if (error) {
+			kfree(overwrite_flags);
 			return error;
+		}
 
Quoted 7 lines

drivers/memstick/core/ms_block.c static int msb_ftl_scan(struct msb_data *msb) · line 1417

Quoted 2 lines
drivers/memstick/core/ms_block.c +0 -0
 		lba = be16_to_cpu(extra.logical_address);
 		managment_flag = extra.management_flag;

Indeed. I need to be more careful with this,
I'll do another review of the code, maybe I spot anything else.

[email protected]> :-(