Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: fadump: use lock guard for mutex

use scoped_guard for scope based resource management of mutex.
This would make the code simpler and easier to maintain.

More details on lock guards can be found at
https://lore.kernel.org/all/20230612093537.614161713@infradead.org/T/#u

Reviewed-by: Srikar Dronamraju <srikar@linux.ibm.com>
Signed-off-by: Shrikanth Hegde <sshegde@linux.ibm.com>
Tested-by: Venkat Rao Bagalkote <venkat88@linux.ibm.com>
Reviewed-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250505075333.184463-4-sshegde@linux.ibm.com

authored by

Shrikanth Hegde and committed by
Madhavan Srinivasan
56534636 6a21d3c5

+4 -7
+4 -7
arch/powerpc/kernel/fadump.c
··· 1373 1373 1374 1374 static void fadump_invalidate_release_mem(void) 1375 1375 { 1376 - mutex_lock(&fadump_mutex); 1377 - if (!fw_dump.dump_active) { 1378 - mutex_unlock(&fadump_mutex); 1379 - return; 1376 + scoped_guard(mutex, &fadump_mutex) { 1377 + if (!fw_dump.dump_active) 1378 + return; 1379 + fadump_cleanup(); 1380 1380 } 1381 - 1382 - fadump_cleanup(); 1383 - mutex_unlock(&fadump_mutex); 1384 1381 1385 1382 fadump_free_elfcorehdr_buf(); 1386 1383 fadump_release_memory(fw_dump.boot_mem_top, memblock_end_of_DRAM());