public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Kees Cook <keescook@chromium.org>
Cc: Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] pstore: Tidy up an error check
Date: Wed, 2 Dec 2020 23:00:21 +0300	[thread overview]
Message-ID: <20201202200021.GJ2789@kadam> (raw)
In-Reply-To: <202012021124.ADBFCE999@keescook>

On Wed, Dec 02, 2020 at 11:25:46AM -0800, Kees Cook wrote:
> On Wed, Dec 02, 2020 at 09:45:31AM +0300, Dan Carpenter wrote:
> > The crypto_alloc_comp() function never returns NULL, it returns error
> > pointers on error.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> I replied to an identical patch yesterday, actually:
> https://lore.kernel.org/lkml/202012011215.B9BF24A6D@keescook/ 
> 
> Using IS_ERR_OR_NULL() is more robust, and this isn't fast path, so I'd
> prefer to keep it that way.
> 

The NULL return doesn't make any sense though because crypto_alloc_comp()
isn't optional...  When a function returns both error pointers and NULLs
then the NULL is special kind of success.

	p = get_feature();

If "p" is an error pointer that means an error happened.  If "p" is NULL
that means the feature is disabled in the .config or whatever.  We can't
return a valid pointer because the feature doesn't exist but it's also
not an error so it doesn't return an error pointer.  The code should
not print a warning, maybe an info level printk at most.  Then the
driver should continue operating with the feature turned off.

Two of the callers for crypto_alloc_comp() check for error pointers and
NULL and three only check for error pointers.  It's inconsistent.

regards,
dan carpenter


      reply	other threads:[~2020-12-02 20:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-02  6:45 [PATCH] pstore: Tidy up an error check Dan Carpenter
2020-12-02 19:25 ` Kees Cook
2020-12-02 20:00   ` Dan Carpenter [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:
  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=20201202200021.GJ2789@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=keescook@chromium.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tony.luck@intel.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