netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nathan Chancellor <natechancellor@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Karsten Keil <isdn@linux-pingi.de>,
	"David S. Miller" <davem@davemloft.net>,
	Nick Desaulniers <ndesaulniers@google.com>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] isdn: isdnloop: fix pointer dereference bug
Date: Thu, 7 Mar 2019 08:17:42 -0700	[thread overview]
Message-ID: <20190307151742.GC20201@archlinux-ryzen> (raw)
In-Reply-To: <20190307093241.3380715-1-arnd@arndb.de>

On Thu, Mar 07, 2019 at 10:32:07AM +0100, Arnd Bergmann wrote:
> clang has spotted an ancient code bug and warns about it with:
> 
> drivers/isdn/isdnloop/isdnloop.c:573:12: error: address of array 'card->rcard' will always evaluate to 'true' [-Werror,-Wpointer-bool-conversion]
> 
> This is an array of pointers, so we should check if a specific
> pointer exists in the array before using it, not whether the
> array itself exists.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> ---
>  drivers/isdn/isdnloop/isdnloop.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/isdn/isdnloop/isdnloop.c b/drivers/isdn/isdnloop/isdnloop.c
> index f4253d468ae1..755c6bbc9553 100644
> --- a/drivers/isdn/isdnloop/isdnloop.c
> +++ b/drivers/isdn/isdnloop/isdnloop.c
> @@ -570,7 +570,7 @@ isdnloop_atimeout(isdnloop_card *card, int ch)
>  	char buf[60];
>  
>  	spin_lock_irqsave(&card->isdnloop_lock, flags);
> -	if (card->rcard) {
> +	if (card->rcard[ch]) {
>  		isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1);
>  		card->rcard[ch]->rcard[card->rch[ch]] = NULL;
>  		card->rcard[ch] = NULL;
> -- 
> 2.20.0
> 

  reply	other threads:[~2019-03-07 15:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-07  9:32 [PATCH] isdn: isdnloop: fix pointer dereference bug Arnd Bergmann
2019-03-07 15:17 ` Nathan Chancellor [this message]
2019-03-07 17:29 ` David Miller

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=20190307151742.GC20201@archlinux-ryzen \
    --to=natechancellor@gmail.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=isdn@linux-pingi.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=netdev@vger.kernel.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).