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

Merge tag 'pstore-v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull pstore updates from Kees Cook:

- Improve backward compatibility with older Chromebooks (Douglas
Anderson)

- Refactor debugfs initialization (Greg KH)

- Fix double-free in pstore_mkfile() failure path (Norbert Manthey)

* tag 'pstore-v5.3-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
pstore: Fix double-free in pstore_mkfile() failure path
pstore: no need to check return value of debugfs_create functions
pstore/ram: Improve backward compatibility with older Chromebooks

+29 -23
+2 -16
fs/pstore/ftrace.c
··· 112 112 113 113 void pstore_register_ftrace(void) 114 114 { 115 - struct dentry *file; 116 - 117 115 if (!psinfo->write) 118 116 return; 119 117 120 118 pstore_ftrace_dir = debugfs_create_dir("pstore", NULL); 121 - if (!pstore_ftrace_dir) { 122 - pr_err("%s: unable to create pstore directory\n", __func__); 123 - return; 124 - } 125 119 126 - file = debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, 127 - NULL, &pstore_knob_fops); 128 - if (!file) { 129 - pr_err("%s: unable to create record_ftrace file\n", __func__); 130 - goto err_file; 131 - } 132 - 133 - return; 134 - err_file: 135 - debugfs_remove(pstore_ftrace_dir); 120 + debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, NULL, 121 + &pstore_knob_fops); 136 122 } 137 123 138 124 void pstore_unregister_ftrace(void)
+6 -7
fs/pstore/inode.c
··· 318 318 goto fail; 319 319 inode->i_mode = S_IFREG | 0444; 320 320 inode->i_fop = &pstore_file_operations; 321 - private = kzalloc(sizeof(*private), GFP_KERNEL); 322 - if (!private) 323 - goto fail_alloc; 324 - private->record = record; 325 - 326 321 scnprintf(name, sizeof(name), "%s-%s-%llu%s", 327 322 pstore_type_to_name(record->type), 328 323 record->psi->name, record->id, 329 324 record->compressed ? ".enc.z" : ""); 330 325 326 + private = kzalloc(sizeof(*private), GFP_KERNEL); 327 + if (!private) 328 + goto fail_inode; 329 + 331 330 dentry = d_alloc_name(root, name); 332 331 if (!dentry) 333 332 goto fail_private; 334 333 334 + private->record = record; 335 335 inode->i_size = private->total_size = size; 336 - 337 336 inode->i_private = private; 338 337 339 338 if (record->time.tv_sec) ··· 348 349 349 350 fail_private: 350 351 free_pstore_private(private); 351 - fail_alloc: 352 + fail_inode: 352 353 iput(inode); 353 354 354 355 fail:
+21
fs/pstore/ram.c
··· 655 655 struct ramoops_platform_data *pdata) 656 656 { 657 657 struct device_node *of_node = pdev->dev.of_node; 658 + struct device_node *parent_node; 658 659 struct resource *res; 659 660 u32 value; 660 661 int ret; ··· 689 688 parse_size("flags", pdata->flags); 690 689 691 690 #undef parse_size 691 + 692 + /* 693 + * Some old Chromebooks relied on the kernel setting the 694 + * console_size and pmsg_size to the record size since that's 695 + * what the downstream kernel did. These same Chromebooks had 696 + * "ramoops" straight under the root node which isn't 697 + * according to the current upstream bindings (though it was 698 + * arguably acceptable under a prior version of the bindings). 699 + * Let's make those old Chromebooks work by detecting that 700 + * we're not a child of "reserved-memory" and mimicking the 701 + * expected behavior. 702 + */ 703 + parent_node = of_get_parent(of_node); 704 + if (!of_node_name_eq(parent_node, "reserved-memory") && 705 + !pdata->console_size && !pdata->ftrace_size && 706 + !pdata->pmsg_size && !pdata->ecc_info.ecc_size) { 707 + pdata->console_size = pdata->record_size; 708 + pdata->pmsg_size = pdata->record_size; 709 + } 710 + of_node_put(parent_node); 692 711 693 712 return 0; 694 713 }