@@ -2273,6 +2273,7 @@ static const struct nand_controller_ops ns_controller_ops = {
2273
2273
*/
2274
2274
static int __init ns_init_module (void )
2275
2275
{
2276
+ struct list_head * pos , * n ;
2276
2277
struct nand_chip * chip ;
2277
2278
struct nandsim * ns ;
2278
2279
int ret ;
@@ -2340,11 +2341,11 @@ static int __init ns_init_module(void)
2340
2341
2341
2342
ret = ns_parse_weakpages ();
2342
2343
if (ret )
2343
- goto error ;
2344
+ goto free_wb_list ;
2344
2345
2345
2346
ret = ns_parse_gravepages ();
2346
2347
if (ret )
2347
- goto error ;
2348
+ goto free_wp_list ;
2348
2349
2349
2350
nand_controller_init (& ns -> base );
2350
2351
ns -> base .ops = & ns_controller_ops ;
@@ -2353,7 +2354,7 @@ static int __init ns_init_module(void)
2353
2354
ret = nand_scan (chip , 1 );
2354
2355
if (ret ) {
2355
2356
NS_ERR ("Could not scan NAND Simulator device\n" );
2356
- goto error ;
2357
+ goto free_gp_list ;
2357
2358
}
2358
2359
2359
2360
if (overridesize ) {
@@ -2412,9 +2413,23 @@ static int __init ns_init_module(void)
2412
2413
kfree (erase_block_wear );
2413
2414
cleanup_nand :
2414
2415
nand_cleanup (chip );
2416
+ free_gp_list :
2417
+ list_for_each_safe (pos , n , & grave_pages ) {
2418
+ list_del (pos );
2419
+ kfree (list_entry (pos , struct grave_page , list ));
2420
+ }
2421
+ free_wp_list :
2422
+ list_for_each_safe (pos , n , & weak_pages ) {
2423
+ list_del (pos );
2424
+ kfree (list_entry (pos , struct weak_page , list ));
2425
+ }
2426
+ free_wb_list :
2427
+ list_for_each_safe (pos , n , & weak_blocks ) {
2428
+ list_del (pos );
2429
+ kfree (list_entry (pos , struct weak_block , list ));
2430
+ }
2415
2431
error :
2416
2432
kfree (ns );
2417
- ns_free_lists ();
2418
2433
2419
2434
return ret ;
2420
2435
}
0 commit comments