Some error path neglects to free the allocated 'cluster_info', causing a memory leak. Change the error jumps to the 'err_free' label to ensure proper cleanup. Fixes: 07adc4cf1ecd ("mm, swap: implement dynamic allocation of swap table") Signed-off-by: Youngjun Park --- mm/swapfile.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index c35bb8593f50..6dc0e7a738bc 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3339,7 +3339,7 @@ static struct swap_cluster_info *setup_clusters(struct swap_info_struct *si, */ err = swap_cluster_setup_bad_slot(cluster_info, 0); if (err) - goto err; + goto err_free; for (i = 0; i < swap_header->info.nr_badpages; i++) { unsigned int page_nr = swap_header->info.badpages[i]; @@ -3347,12 +3347,12 @@ static struct swap_cluster_info *setup_clusters(struct swap_info_struct *si, continue; err = swap_cluster_setup_bad_slot(cluster_info, page_nr); if (err) - goto err; + goto err_free; } for (i = maxpages; i < round_up(maxpages, SWAPFILE_CLUSTER); i++) { err = swap_cluster_setup_bad_slot(cluster_info, i); if (err) - goto err; + goto err_free; } INIT_LIST_HEAD(&si->free_clusters); -- 2.34.1