Skip to content

Commit 6b44fcc

Browse files
committed
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
2 parents 753c8d9 + 4c6d80e commit 6b44fcc

3 files changed

Lines changed: 29 additions & 23 deletions

File tree

fs/pstore/ftrace.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,27 +112,13 @@ static struct dentry *pstore_ftrace_dir;
112112

113113
void pstore_register_ftrace(void)
114114
{
115-
struct dentry *file;
116-
117115
if (!psinfo->write)
118116
return;
119117

120118
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-
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-
}
132119

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);
136122
}
137123

138124
void pstore_unregister_ftrace(void)

fs/pstore/inode.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,22 +318,21 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
318318
goto fail;
319319
inode->i_mode = S_IFREG | 0444;
320320
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-
326321
scnprintf(name, sizeof(name), "%s-%s-%llu%s",
327322
pstore_type_to_name(record->type),
328323
record->psi->name, record->id,
329324
record->compressed ? ".enc.z" : "");
330325

326+
private = kzalloc(sizeof(*private), GFP_KERNEL);
327+
if (!private)
328+
goto fail_inode;
329+
331330
dentry = d_alloc_name(root, name);
332331
if (!dentry)
333332
goto fail_private;
334333

334+
private->record = record;
335335
inode->i_size = private->total_size = size;
336-
337336
inode->i_private = private;
338337

339338
if (record->time.tv_sec)
@@ -349,7 +348,7 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
349348

350349
fail_private:
351350
free_pstore_private(private);
352-
fail_alloc:
351+
fail_inode:
353352
iput(inode);
354353

355354
fail:

fs/pstore/ram.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -655,6 +655,7 @@ static int ramoops_parse_dt(struct platform_device *pdev,
655655
struct ramoops_platform_data *pdata)
656656
{
657657
struct device_node *of_node = pdev->dev.of_node;
658+
struct device_node *parent_node;
658659
struct resource *res;
659660
u32 value;
660661
int ret;
@@ -689,6 +690,26 @@ static int ramoops_parse_dt(struct platform_device *pdev,
689690

690691
#undef parse_size
691692

693+
/*
694+
* Some old Chromebooks relied on the kernel setting the
695+
* console_size and pmsg_size to the record size since that's
696+
* what the downstream kernel did. These same Chromebooks had
697+
* "ramoops" straight under the root node which isn't
698+
* according to the current upstream bindings (though it was
699+
* arguably acceptable under a prior version of the bindings).
700+
* Let's make those old Chromebooks work by detecting that
701+
* we're not a child of "reserved-memory" and mimicking the
702+
* expected behavior.
703+
*/
704+
parent_node = of_get_parent(of_node);
705+
if (!of_node_name_eq(parent_node, "reserved-memory") &&
706+
!pdata->console_size && !pdata->ftrace_size &&
707+
!pdata->pmsg_size && !pdata->ecc_info.ecc_size) {
708+
pdata->console_size = pdata->record_size;
709+
pdata->pmsg_size = pdata->record_size;
710+
}
711+
of_node_put(parent_node);
712+
692713
return 0;
693714
}
694715

0 commit comments

Comments
 (0)