Skip to content

Commit 2083dfe

Browse files
davidhildenbrandmstsirkin
authored andcommitted
fs/proc/vmcore: replace vmcoredd_mutex by vmcore_mutex
Now that we have a mutex that synchronizes against opening of the vmcore, let's use that one to replace vmcoredd_mutex: there is no need to have two separate ones. This is a preparation for properly preventing vmcore modifications after the vmcore was opened. Signed-off-by: David Hildenbrand <[email protected]> Message-Id: <[email protected]> Acked-by: Andrew Morton <[email protected]> Signed-off-by: Michael S. Tsirkin <[email protected]>
1 parent cdbc697 commit 2083dfe

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

fs/proc/vmcore.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ static struct proc_dir_entry *proc_vmcore;
5353
#ifdef CONFIG_PROC_VMCORE_DEVICE_DUMP
5454
/* Device Dump list and mutex to synchronize access to list */
5555
static LIST_HEAD(vmcoredd_list);
56-
static DEFINE_MUTEX(vmcoredd_mutex);
5756

5857
static bool vmcoredd_disabled;
5958
core_param(novmcoredd, vmcoredd_disabled, bool, 0);
@@ -248,7 +247,7 @@ static int vmcoredd_copy_dumps(struct iov_iter *iter, u64 start, size_t size)
248247
size_t tsz;
249248
char *buf;
250249

251-
mutex_lock(&vmcoredd_mutex);
250+
mutex_lock(&vmcore_mutex);
252251
list_for_each_entry(dump, &vmcoredd_list, list) {
253252
if (start < offset + dump->size) {
254253
tsz = min(offset + (u64)dump->size - start, (u64)size);
@@ -269,7 +268,7 @@ static int vmcoredd_copy_dumps(struct iov_iter *iter, u64 start, size_t size)
269268
}
270269

271270
out_unlock:
272-
mutex_unlock(&vmcoredd_mutex);
271+
mutex_unlock(&vmcore_mutex);
273272
return ret;
274273
}
275274

@@ -283,7 +282,7 @@ static int vmcoredd_mmap_dumps(struct vm_area_struct *vma, unsigned long dst,
283282
size_t tsz;
284283
char *buf;
285284

286-
mutex_lock(&vmcoredd_mutex);
285+
mutex_lock(&vmcore_mutex);
287286
list_for_each_entry(dump, &vmcoredd_list, list) {
288287
if (start < offset + dump->size) {
289288
tsz = min(offset + (u64)dump->size - start, (u64)size);
@@ -306,7 +305,7 @@ static int vmcoredd_mmap_dumps(struct vm_area_struct *vma, unsigned long dst,
306305
}
307306

308307
out_unlock:
309-
mutex_unlock(&vmcoredd_mutex);
308+
mutex_unlock(&vmcore_mutex);
310309
return ret;
311310
}
312311
#endif /* CONFIG_MMU */
@@ -1518,9 +1517,9 @@ int vmcore_add_device_dump(struct vmcoredd_data *data)
15181517
dump->size = data_size;
15191518

15201519
/* Add the dump to driver sysfs list */
1521-
mutex_lock(&vmcoredd_mutex);
1520+
mutex_lock(&vmcore_mutex);
15221521
list_add_tail(&dump->list, &vmcoredd_list);
1523-
mutex_unlock(&vmcoredd_mutex);
1522+
mutex_unlock(&vmcore_mutex);
15241523

15251524
vmcoredd_update_size(data_size);
15261525
return 0;
@@ -1538,7 +1537,7 @@ EXPORT_SYMBOL(vmcore_add_device_dump);
15381537
static void vmcore_free_device_dumps(void)
15391538
{
15401539
#ifdef CONFIG_PROC_VMCORE_DEVICE_DUMP
1541-
mutex_lock(&vmcoredd_mutex);
1540+
mutex_lock(&vmcore_mutex);
15421541
while (!list_empty(&vmcoredd_list)) {
15431542
struct vmcoredd_node *dump;
15441543

@@ -1548,7 +1547,7 @@ static void vmcore_free_device_dumps(void)
15481547
vfree(dump->buf);
15491548
vfree(dump);
15501549
}
1551-
mutex_unlock(&vmcoredd_mutex);
1550+
mutex_unlock(&vmcore_mutex);
15521551
#endif /* CONFIG_PROC_VMCORE_DEVICE_DUMP */
15531552
}
15541553

0 commit comments

Comments
 (0)