Re: [PATCH] mm/memblock: validate the creation of debugfs files

Andrew Morton
2015-08-14T21:19:47Z

On Sat, 15 Aug 2015 01:03:31 +0600 Alexander Kuleshov <kuleshovmail@gmail.com> wrote:

> Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>

There's no changelog.

> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -1692,16 +1692,34 @@ static const struct file_operations memblock_debug_fops = {
>
> static int __init memblock_init_debugfs(void)
> {
> + struct dentry *f;
> struct dentry *root = debugfs_create_dir("memblock", NULL);
> if (!root)
> return -ENXIO;
> - debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops);
> - debugfs_create_file("reserved", S_IRUGO, root, &memblock.reserved, &memblock_debug_fops);
> +
> + f = debugfs_create_file("memory", S_IRUGO, root, &memblock.memory, &memblock_debug_fops);
> + if (!f) {
> + pr_err("Failed to create memory debugfs file\n");
> + goto err_out;

Why? Ignoring the debugfs API return values is standard practice.