kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Nigel Christian <nigel.l.christian@gmail.com>
Cc: kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] mm: hugetlb: checking for IS_ERR() instead of NULL
Date: Wed, 2 Jun 2021 17:47:52 +0300	[thread overview]
Message-ID: <20210602144752.GC10983@kadam> (raw)
In-Reply-To: <20210601205006.GA10983@kadam>

On Tue, Jun 01, 2021 at 11:50:06PM +0300, Dan Carpenter wrote:
> On Tue, Jun 01, 2021 at 10:51:23PM +0300, Dan Carpenter wrote:
> > The other thing which might be interesting is if you pass a NULL
> > to IS_ERR() and then dereference the NULL then print a warning about
> > that.  This has a lot of overlaps with some of my existing checks, but
> > it's still a new idea so it belongs in a separate check.  It's fine and
> > good even if one bug triggers a lot of different warnings.  I'll write
> > that, hang on, brb.
> 
> 100% untested.  :)  I'll test it tonight.
> 

This test is decent, but I ended up making a few changes:

1)  My devel version of Smatch had a new bug in it which caused some
    false positives.  Fixed now, hopefully.

2)  The test:

	if (get_state_expr(my_id, expr) != &null)
		return;

    check was not strict enough.  I realized that I knew that from
    square one but I was lazy.  So now I have introduced a global helper
    function and updated the code:

bool expr_has_possible_state(int owner, struct expression *expr, struct smatch_state *state)
{
        struct sm_state *sm;

        sm = get_sm_state_expr(owner, expr);
        if (!sm)
                return false;

        return slist_has_state(sm->possible, state);
}

    I replaced the test with:

	if (!expr_has_possible_state(my_id, expr, &null))

3)  The warning message was too vague and too similar to other warning
    messages.  It should be something unique to the test.  It's now:

	sm_error("potential NULL/IS_ERR bug '%s'", name);

I'll post the results tomorrow.

regards,
dan carpenter


  parent reply	other threads:[~2021-06-02 14:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-01  9:25 [PATCH] mm: hugetlb: checking for IS_ERR() instead of NULL Dan Carpenter
2021-06-01 10:52 ` Mina Almasry
2021-06-01 17:54 ` Nigel Christian
2021-06-01 19:00   ` Dan Carpenter
2021-06-01 19:51     ` Dan Carpenter
2021-06-01 20:50       ` Dan Carpenter
2021-06-01 21:23         ` Nigel Christian
2021-06-02  6:11           ` Dan Carpenter
2021-06-02 14:47         ` Dan Carpenter [this message]
2021-06-02 16:01           ` Nigel Christian
2021-06-04 13:34           ` Dan Carpenter
2021-06-04 14:14             ` Nigel Christian
2021-06-04 14:21               ` Dan Carpenter
2021-06-02 14:22       ` Dan Carpenter
2021-06-02 15:57         ` Nigel Christian

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=20210602144752.GC10983@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=nigel.l.christian@gmail.com \
    /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).