From: Brian Norris <computersforpeace@gmail.com>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Boris Brezillon <boris.brezillon@free-electrons.com>,
Richard Weinberger <richard@nod.at>,
linux-mtd@lists.infradead.org, kernel@pengutronix.de
Subject: Re: [PATCH] mtd: nandsim: remove debugfs entries in error path
Date: Thu, 24 Aug 2017 21:22:03 -0700 [thread overview]
Message-ID: <20170825042203.GB68252@google.com> (raw)
In-Reply-To: <20170823070304.1336-1-u.kleine-koenig@pengutronix.de>
Hi,
On Wed, Aug 23, 2017 at 09:03:04AM +0200, Uwe Kleine-König wrote:
> The debugfs entries must be removed before an error is returned in the
> probe function. Otherwise another try to load the module fails and when
> the debugfs files are accessed without the module loaded, the kernel
> still tries to call a function in that module.
>
> Fixes: 5346c27c5fed ("mtd: nandsim: Introduce debugfs infrastructure")
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
> drivers/mtd/nand/nandsim.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c
> index 03a0d057bf2f..e4211c3cc49b 100644
> --- a/drivers/mtd/nand/nandsim.c
> +++ b/drivers/mtd/nand/nandsim.c
> @@ -2373,6 +2373,7 @@ static int __init ns_init_module(void)
> return 0;
>
> err_exit:
> + nandsim_debugfs_remove(nand);
The 'err_exit' label is used by error paths that occur before the
debugfs entries are registered. But I guess that's OK, since
debugfs_remove_recursive() handles NULL arguments fine?
We also have the same mismatch with init_nandsim()/free_nandsim(), which
is also similarly safe because of the nature of kfree(), vfree(), and
the fact that most of those are guarded with NULL checks anyway... So
it's just confusing and potentially dangerous for future developers --
but not wrong.
Given this code will promptly go away with the for-4.14 material, I
suppose this isn't that bad.
I'll look to queue this up and send to Linus within a day.
Thanks,
Brian
> free_nandsim(nand);
> nand_release(nsmtd);
> for (i = 0;i < ARRAY_SIZE(nand->partitions); ++i)
> --
> 2.11.0
>
next prev parent reply other threads:[~2017-08-25 4:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-23 7:03 [PATCH] mtd: nandsim: remove debugfs entries in error path Uwe Kleine-König
2017-08-23 8:40 ` Richard Weinberger
2017-08-23 8:40 ` Boris Brezillon
2017-08-23 9:12 ` Uwe Kleine-König
2017-08-25 4:22 ` Brian Norris [this message]
2017-08-25 5:41 ` Uwe Kleine-König
2017-08-25 21:35 ` Brian Norris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170825042203.GB68252@google.com \
--to=computersforpeace@gmail.com \
--cc=boris.brezillon@free-electrons.com \
--cc=kernel@pengutronix.de \
--cc=linux-mtd@lists.infradead.org \
--cc=richard@nod.at \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox