isdn: isdnloop: fix pointer dereference bug
Subsystems (2)
PATCH 1/1 isdn: isdnloop: fix pointer dereference bug
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.
--- drivers/isdn/isdnloop/isdnloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/isdn/isdnloop/isdnloop.c +1 -1
@@ -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 ;
Signature · 1 line
2.20.0
Quoted 9 lines · Arnd Bergmann
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 <[email protected]>
Quoted 20 lines
--- drivers/isdn/isdnloop/isdnloop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/isdn/isdnloop/isdnloop.c +1
-1@@ -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 ;Signature · 1 line
2.20.0
From: Arnd Bergmann <[email protected]>
Date: Thu, 7 Mar 2019 10:32:07 +0100
Quoted 9 lines
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 <[email protected]>
Applied.