* [PATCH] isdn: isdnloop: fix pointer dereference bug
@ 2019-03-07 9:32 Arnd Bergmann
2019-03-07 15:17 ` Nathan Chancellor
2019-03-07 17:29 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-03-07 9:32 UTC (permalink / raw)
To: Karsten Keil, David S. Miller
Cc: Nick Desaulniers, Arnd Bergmann, netdev, linux-kernel
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>
---
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] isdn: isdnloop: fix pointer dereference bug
2019-03-07 9:32 [PATCH] isdn: isdnloop: fix pointer dereference bug Arnd Bergmann
@ 2019-03-07 15:17 ` Nathan Chancellor
2019-03-07 17:29 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2019-03-07 15:17 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Karsten Keil, David S. Miller, Nick Desaulniers, netdev, linux-kernel
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
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] isdn: isdnloop: fix pointer dereference bug
2019-03-07 9:32 [PATCH] isdn: isdnloop: fix pointer dereference bug Arnd Bergmann
2019-03-07 15:17 ` Nathan Chancellor
@ 2019-03-07 17:29 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-03-07 17:29 UTC (permalink / raw)
To: arnd; +Cc: isdn, ndesaulniers, netdev, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Date: Thu, 7 Mar 2019 10:32:07 +0100
> 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>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-07 17:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-07 9:32 [PATCH] isdn: isdnloop: fix pointer dereference bug Arnd Bergmann
2019-03-07 15:17 ` Nathan Chancellor
2019-03-07 17:29 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.