archive mirror
 help / color / mirror / Atom feed
From: Brendan Higgins <>
To: David Gow <>
Cc: Dan Carpenter <>,
	Shuah Khan <>,
	Andrew Morton <>,
	Kees Cook <>,
	KUnit Development <>,
	Linux Kernel Mailing List <>
Subject: Re: [PATCH linux-kselftest/test v4] lib/list-test: add a test for the 'list' doubly linked list
Date: Wed, 23 Oct 2019 14:25:49 -0700	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

On Tue, Oct 22, 2019 at 3:13 PM David Gow <> wrote:
> On Sat, Oct 19, 2019 at 1:27 AM Dan Carpenter <> wrote:
> >
> > On Fri, Oct 18, 2019 at 02:55:49PM -0700, David Gow wrote:
> > > +     list4 = kzalloc(sizeof(*list4), GFP_KERNEL);
> > > +     KUNIT_ASSERT_NOT_ERR_OR_NULL(test, list4);
> >
> > Why not just use GFP_KERNEL | GFP_NOFAIL and remove the check?
> I've sent a new version of the patch out (v5) which uses __GFP_NOFAIL instead.
> The idea had been to exercise KUnit's assertion functionality, in the
> hope that it'd allow the test to fail (but potentially allow other
> tests to still run) in the case of allocation failure. Given that
> we're only allocating enough to store ~4 pointers in total, though,
> that's probably of little use.
> > kzalloc() can't return error pointers.  If this were an IS_ERR_OR_NULL()
> > check then it would generate a static checker warning, but static
> > checkers don't know about KUNIT_ASSERT_NOT_ERR_OR_NULL() yet so you're
> > safe.
> Alas, KUnit doesn't have a KUNIT_ASSERT_NOT_NULL() macro, and I'd
> assumed it was not dangerous (even if not ideal) to check for error
> pointers, even if kzalloc() can't return them.

Maybe it would be good for us (not in this case, just generally
speaking) to add a KUNIT_ASSERT_NOT_NULL() and friends?

> Perhaps it'd make sense to add a convenient way of checking the
> NULL-ness of pointers to KUnit (it's possible with the
> KUNIT_ASSERT_PTR_EQ(), but requires a bit of casting to make the type
> checker happy) in the future. Once KUnit is properly upstream, it may
> be worth teaching the static analysis tools about these functions to
> avoid having warnings in these sorts of tests.
> For now, though, (and for this test in particular), I agree with the
> suggestion of just using __GFP_NOFAIL.
> Thanks a lot for the comments,
> -- David

      reply	other threads:[~2019-10-23 21:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-18 21:55 [PATCH linux-kselftest/test v4] lib/list-test: add a test for the 'list' doubly linked list David Gow
2019-10-19  8:27 ` Dan Carpenter
2019-10-22 22:13   ` David Gow
2019-10-23 21:25     ` Brendan Higgins [this message]

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \

* 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).