From: Matthew Wilcox <willy@infradead.org>
To: Baolin Wang <baolin.wang@linaro.org>
Cc: linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>,
Arnd Bergmann <arnd@arndb.de>, Mark Brown <broonie@kernel.org>
Subject: Re: [PATCH] mm: dmapool: Check the dma pool name
Date: Wed, 30 May 2018 08:41:10 -0700 [thread overview]
Message-ID: <20180530154110.GA22184@bombadil.infradead.org> (raw)
In-Reply-To: <20180530151327.GA13951@bombadil.infradead.org>
On Wed, May 30, 2018 at 08:13:27AM -0700, Matthew Wilcox wrote:
> On Wed, May 30, 2018 at 08:14:09PM +0800, Baolin Wang wrote:
> > On 30 May 2018 at 20:01, Matthew Wilcox <willy@infradead.org> wrote:
> > > On Wed, May 30, 2018 at 07:28:43PM +0800, Baolin Wang wrote:
> > >> It will be crash if we pass one NULL name when creating one dma pool,
> > >> so we should check the passing name when copy it to dma pool.
> > >
> > > NAK. Crashing is the appropriate thing to do. Fix the caller to not
> > > pass NULL.
> > >
> > > If you permit NULL to be passed then you're inviting crashes or just
> > > bad reporting later when pool->name is printed.
> >
> > I think it just prints one NULL pool name. Sometimes the device
> > doesn't care the dma pool names, so I think we can make code more
> > solid to valid the passing parameters like other code does.
> > Or can we add check to return NULL when the passing name is NULL
> > instead of crashing the kernel? Thanks.
>
> No. Fix your driver.
Let me elaborate on this. Kernel code is supposed to be "reasonable".
That means we don't check every argument to every function for sanity,
unless it's going to cause trouble later. Crashing immediately with
a bogus argument is fine; you can see the problem and fix it immediately.
Returning NULL with a bad argument is actually worse; you won't know why
the function returned NULL (maybe we're out of memory?) and you'll have
a more complex debugging experience.
Sometimes it makes sense to accept a NULL pointer and do something
reasonable, like kfree(). In this case, we can eliminate checks in all
the callers. But we don't, in general, put sanity checks on arguments
without a good reason.
Your reasons aren't good. "The driver doesn't care" -- well, just pass
the driver's name, then.
next prev parent reply other threads:[~2018-05-30 15:41 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-30 11:28 [PATCH] mm: dmapool: Check the dma pool name Baolin Wang
2018-05-30 12:01 ` Matthew Wilcox
2018-05-30 12:14 ` Baolin Wang
2018-05-30 15:13 ` Matthew Wilcox
2018-05-30 15:41 ` Matthew Wilcox [this message]
2018-05-31 2:34 ` Baolin Wang
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=20180530154110.GA22184@bombadil.infradead.org \
--to=willy@infradead.org \
--cc=arnd@arndb.de \
--cc=baolin.wang@linaro.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
/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;
as well as URLs for NNTP newsgroup(s).