Commit 6b44fccd authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents 753c8d9b 4c6d80e1
Loading
Loading
Loading
Loading
+2 −16
Original line number Original line Diff line number Diff line
@@ -112,27 +112,13 @@ static struct dentry *pstore_ftrace_dir;


void pstore_register_ftrace(void)
void pstore_register_ftrace(void)
{
{
	struct dentry *file;

	if (!psinfo->write)
	if (!psinfo->write)
		return;
		return;


	pstore_ftrace_dir = debugfs_create_dir("pstore", NULL);
	pstore_ftrace_dir = debugfs_create_dir("pstore", NULL);
	if (!pstore_ftrace_dir) {
		pr_err("%s: unable to create pstore directory\n", __func__);
		return;
	}


	file = debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir,
	debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, NULL,
				   NULL, &pstore_knob_fops);
			    &pstore_knob_fops);
	if (!file) {
		pr_err("%s: unable to create record_ftrace file\n", __func__);
		goto err_file;
	}

	return;
err_file:
	debugfs_remove(pstore_ftrace_dir);
}
}


void pstore_unregister_ftrace(void)
void pstore_unregister_ftrace(void)
+6 −7
Original line number Original line Diff line number Diff line
@@ -318,22 +318,21 @@ int pstore_mkfile(struct dentry *root, struct pstore_record *record)
		goto fail;
		goto fail;
	inode->i_mode = S_IFREG | 0444;
	inode->i_mode = S_IFREG | 0444;
	inode->i_fop = &pstore_file_operations;
	inode->i_fop = &pstore_file_operations;
	private = kzalloc(sizeof(*private), GFP_KERNEL);
	if (!private)
		goto fail_alloc;
	private->record = record;

	scnprintf(name, sizeof(name), "%s-%s-%llu%s",
	scnprintf(name, sizeof(name), "%s-%s-%llu%s",
			pstore_type_to_name(record->type),
			pstore_type_to_name(record->type),
			record->psi->name, record->id,
			record->psi->name, record->id,
			record->compressed ? ".enc.z" : "");
			record->compressed ? ".enc.z" : "");


	private = kzalloc(sizeof(*private), GFP_KERNEL);
	if (!private)
		goto fail_inode;

	dentry = d_alloc_name(root, name);
	dentry = d_alloc_name(root, name);
	if (!dentry)
	if (!dentry)
		goto fail_private;
		goto fail_private;


	private->record = record;
	inode->i_size = private->total_size = size;
	inode->i_size = private->total_size = size;

	inode->i_private = private;
	inode->i_private = private;


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


fail_private:
fail_private:
	free_pstore_private(private);
	free_pstore_private(private);
fail_alloc:
fail_inode:
	iput(inode);
	iput(inode);


fail:
fail:
+21 −0
Original line number Original line Diff line number Diff line
@@ -655,6 +655,7 @@ static int ramoops_parse_dt(struct platform_device *pdev,
			    struct ramoops_platform_data *pdata)
			    struct ramoops_platform_data *pdata)
{
{
	struct device_node *of_node = pdev->dev.of_node;
	struct device_node *of_node = pdev->dev.of_node;
	struct device_node *parent_node;
	struct resource *res;
	struct resource *res;
	u32 value;
	u32 value;
	int ret;
	int ret;
@@ -689,6 +690,26 @@ static int ramoops_parse_dt(struct platform_device *pdev,


#undef parse_size
#undef parse_size


	/*
	 * Some old Chromebooks relied on the kernel setting the
	 * console_size and pmsg_size to the record size since that's
	 * what the downstream kernel did.  These same Chromebooks had
	 * "ramoops" straight under the root node which isn't
	 * according to the current upstream bindings (though it was
	 * arguably acceptable under a prior version of the bindings).
	 * Let's make those old Chromebooks work by detecting that
	 * we're not a child of "reserved-memory" and mimicking the
	 * expected behavior.
	 */
	parent_node = of_get_parent(of_node);
	if (!of_node_name_eq(parent_node, "reserved-memory") &&
	    !pdata->console_size && !pdata->ftrace_size &&
	    !pdata->pmsg_size && !pdata->ecc_info.ecc_size) {
		pdata->console_size = pdata->record_size;
		pdata->pmsg_size = pdata->record_size;
	}
	of_node_put(parent_node);

	return 0;
	return 0;
}
}