Commit 2fcc6e20 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman
Browse files

hwpoison-inject: no need to check return value of debugfs_create functions



When calling debugfs functions, there is no need to ever check the
return value.  The function can work or not, but the code logic should
never do something different based on this.

Cc: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: linux-mm@kvack.org
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 282401df
Loading
Loading
Loading
Loading
+22 −45
Original line number Original line Diff line number Diff line
@@ -77,63 +77,40 @@ static void pfn_inject_exit(void)


static int pfn_inject_init(void)
static int pfn_inject_init(void)
{
{
	struct dentry *dentry;

	hwpoison_dir = debugfs_create_dir("hwpoison", NULL);
	hwpoison_dir = debugfs_create_dir("hwpoison", NULL);
	if (hwpoison_dir == NULL)
		return -ENOMEM;


	/*
	/*
	 * Note that the below poison/unpoison interfaces do not involve
	 * Note that the below poison/unpoison interfaces do not involve
	 * hardware status change, hence do not require hardware support.
	 * hardware status change, hence do not require hardware support.
	 * They are mainly for testing hwpoison in software level.
	 * They are mainly for testing hwpoison in software level.
	 */
	 */
	dentry = debugfs_create_file("corrupt-pfn", 0200, hwpoison_dir,
	debugfs_create_file("corrupt-pfn", 0200, hwpoison_dir, NULL,
					  NULL, &hwpoison_fops);
			    &hwpoison_fops);
	if (!dentry)

		goto fail;
	debugfs_create_file("unpoison-pfn", 0200, hwpoison_dir, NULL,

			    &unpoison_fops);
	dentry = debugfs_create_file("unpoison-pfn", 0200, hwpoison_dir,

				     NULL, &unpoison_fops);
	debugfs_create_u32("corrupt-filter-enable", 0600, hwpoison_dir,
	if (!dentry)
			   &hwpoison_filter_enable);
		goto fail;


	debugfs_create_u32("corrupt-filter-dev-major", 0600, hwpoison_dir,
	dentry = debugfs_create_u32("corrupt-filter-enable", 0600,
			   &hwpoison_filter_dev_major);
				    hwpoison_dir, &hwpoison_filter_enable);

	if (!dentry)
	debugfs_create_u32("corrupt-filter-dev-minor", 0600, hwpoison_dir,
		goto fail;
			   &hwpoison_filter_dev_minor);


	dentry = debugfs_create_u32("corrupt-filter-dev-major", 0600,
	debugfs_create_u64("corrupt-filter-flags-mask", 0600, hwpoison_dir,
				    hwpoison_dir, &hwpoison_filter_dev_major);
			   &hwpoison_filter_flags_mask);
	if (!dentry)

		goto fail;
	debugfs_create_u64("corrupt-filter-flags-value", 0600, hwpoison_dir,

			   &hwpoison_filter_flags_value);
	dentry = debugfs_create_u32("corrupt-filter-dev-minor", 0600,
				    hwpoison_dir, &hwpoison_filter_dev_minor);
	if (!dentry)
		goto fail;

	dentry = debugfs_create_u64("corrupt-filter-flags-mask", 0600,
				    hwpoison_dir, &hwpoison_filter_flags_mask);
	if (!dentry)
		goto fail;

	dentry = debugfs_create_u64("corrupt-filter-flags-value", 0600,
				    hwpoison_dir, &hwpoison_filter_flags_value);
	if (!dentry)
		goto fail;


#ifdef CONFIG_MEMCG
#ifdef CONFIG_MEMCG
	dentry = debugfs_create_u64("corrupt-filter-memcg", 0600,
	debugfs_create_u64("corrupt-filter-memcg", 0600, hwpoison_dir,
				    hwpoison_dir, &hwpoison_filter_memcg);
			   &hwpoison_filter_memcg);
	if (!dentry)
		goto fail;
#endif
#endif


	return 0;
	return 0;
fail:
	pfn_inject_exit();
	return -ENOMEM;
}
}


module_init(pfn_inject_init);
module_init(pfn_inject_init);