jsm_tty: Fix a possible null pointer dereference in two functions
PATCH 1/1 jsm_tty: Fix a possible null pointer dereference in two functions
From: Markus Elfring <[email protected]>
Date: Wed, 29 Nov 2017 17:30:36 +0100
Move two debug messages so that a null pointer access can not happen for the variable "ch" in these functions.
This issue was detected by using the Coccinelle software.
--- drivers/tty/serial/jsm/jsm_tty.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/tty/serial/jsm/jsm_tty.c +2 -3
@@ -521,11 +521,10 @@ void jsm_input(struct jsm_channel *ch)int s =0 ;int i =0 ; -jsm_dbg (READ , &ch->ch_bd->pci_dev,"start\n" ); -if (!ch)return ; +jsm_dbg (READ , &ch->ch_bd->pci_dev,"start\n" ); port = &ch->uart_port.state->port; tp = port->tty;
@@ -647,10 +646,10 @@ static void jsm_carrier(struct jsm_channel *ch)int virt_carrier =0 ;int phys_carrier =0 ; -jsm_dbg (CARR , &ch->ch_bd->pci_dev,"start\n" );if (!ch)return ; +jsm_dbg (CARR , &ch->ch_bd->pci_dev,"start\n" ); bd = ch->ch_bd;if (!bd)
Signature · 1 line
2.15.0
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 29 Nov 2017 17:30:36 +0100Move two debug messages so that a null pointer access can not happen for the variable "ch" in these functions.
An actual defect fix!
Here you could probably cc stable too.
Quoted 39 lines
This issue was detected by using the Coccinelle software.
Fixes 669fef464468d3f02d60a5cf725fc097e03c5cb8 ("serial: jsm: Convert jsm_printk to jsm_dbg")Signed-off-by Markus Elfring <[email protected]>--- drivers/tty/serial/jsm/jsm_tty.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/tty/serial/jsm/jsm_tty.c +2
-3@@ -521,11 +521,10 @@ void jsm_input(struct jsm_channel *ch)int s =0 ;int i =0 ; -jsm_dbg (READ , &ch->ch_bd->pci_dev,"start\n" ); -if (!ch)return ; +jsm_dbg (READ , &ch->ch_bd->pci_dev,"start\n" ); port = &ch->uart_port.state->port; tp = port->tty;@@ -647,10 +646,10 @@ static void jsm_carrier(struct jsm_channel *ch)int virt_carrier =0 ;int phys_carrier =0 ; -jsm_dbg (CARR , &ch->ch_bd->pci_dev,"start\n" );if (!ch)return ; +jsm_dbg (CARR , &ch->ch_bd->pci_dev,"start\n" ); bd = ch->ch_bd;if (!bd)
Greg Kroah-Hartman
maintainerQuoted 8 lines · Joe Perches
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 29 Nov 2017 17:30:36 +0100Move two debug messages so that a null pointer access can not happen for the variable "ch" in these functions.
An actual defect fix!
Nope, not at all, this does not "fix" anything.
Quoted 1 line
Here you could probably cc stable too.
Nope, not worth it.
greg k-h
Quoted 11 lines · Greg Kroah-Hartman
Quoted 8 lines · Joe Perches
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 29 Nov 2017 17:30:36 +0100Move two debug messages so that a null pointer access can not happen for the variable "ch" in these functions.
An actual defect fix!
Nope, not at all, this does not "fix" anything.
Well, I believe it does in unusual cases like aCONFIG_DYNAMIC_DEBUG when this is enabled by an
odd +p in the dynamic debug control file.
Quoted 3 lines
Quoted 1 line
Here you could probably cc stable too.
Nope, not worth it.
<shrug>
It's pretty unlikely, but it is an actual defect.
Greg Kroah-Hartman
maintainerQuoted 17 lines · Joe Perches
Quoted 11 lines · Greg Kroah-Hartman
Quoted 8 lines · Joe Perches
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 29 Nov 2017 17:30:36 +0100Move two debug messages so that a null pointer access can not happen for the variable "ch" in these functions.
An actual defect fix!
Nope, not at all, this does not "fix" anything.
Well, I believe it does in unusual cases like a
CONFIG_DYNAMIC_DEBUGwhen this is enabled by an
odd +p in the dynamic debug control file.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Here you could probably cc stable too.
Nope, not worth it.
<shrug>
It's pretty unlikely, but it is an actual defect.
No it is not, those variables will never be set to NULL, so this can never be triggered. Walk up the call chain.
greg k-h
Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · Joe Perches
Quoted 11 lines · Greg Kroah-Hartman
Quoted 8 lines · Joe Perches
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 29 Nov 2017 17:30:36 +0100Move two debug messages so that a null pointer access can not happen for the variable "ch" in these functions.
An actual defect fix!
Nope, not at all, this does not "fix" anything.
Well, I believe it does in unusual cases like a
CONFIG_DYNAMIC_DEBUGwhen this is enabled by an
odd +p in the dynamic debug control file.Quoted 2 lines
Quoted 1 line
Here you could probably cc stable too.
Quoted 8 lines
Quoted 5 lines
Quoted 1 line
Nope, not worth it.
<shrug>
It's pretty unlikely, but it is an actual defect.
No it is not, those variables will never be set to NULL, so this can never be triggered. Walk up the call chain.
Right you are. Local analysis isn't enough. The code could/should be removed, but it's not a defect.
cheers, Joe
Quoted 4 lines
Quoted 1 line
It's pretty unlikely, but it is an actual defect.
No it is not, those variables will never be set to NULL, so this can never be triggered. Walk up the call chain.
If the involved software developers are convinced about the validity of this pointer:
How do you think about to delete the following condition check instead in the discussed function implementations?
if (!ch) return;
Regards,
Markus
Quoted 11 lines · Joe Perches
Quoted 5 lines · SF Markus Elfring
From: Markus Elfring <[email protected]>
Date: Wed, 29 Nov 2017 17:30:36 +0100Move two debug messages so that a null pointer access can not happen for the variable "ch" in these functions.
An actual defect fix!
Here you could probably cc stable too.
These aren't real bugs because "ch" is never NULL.
regards,
dan carpenter
Quoted 5 lines · SF Markus Elfring
Quoted 4 lines
Quoted 1 line
It's pretty unlikely, but it is an actual defect.
No it is not, those variables will never be set to NULL, so this can never be triggered. Walk up the call chain.
Quoted 8 lines
If the involved software developers are convinced about the validity of this pointer:
How do you think about to delete the following condition check instead in the discussed function implementations?
if (!ch) return;
ACK
thanks,
Signature · 2 lines
js suse labs
Quoted 11 lines · SF Markus Elfring
Quoted 4 lines
Quoted 1 line
It's pretty unlikely, but it is an actual defect.
No it is not, those variables will never be set to NULL, so this can never be triggered. Walk up the call chain.
If the involved software developers are convinced about the validity of this pointer:
How do you think about to delete the following condition check instead in the discussed function implementations?
Quoted 7 lines
if (!ch) return;Regards,
Markus
Thanks for the fix.
I was on vacation - but now seeing all the analysis made here, if "ch" can't be NULL then please go ahead and remove the check =)
I observed that this check comes from before Git, so really ancient code...
Cheers,
Guilherme
Re: jsm_tty: Deletion of a null pointer check in two functions?
Quoted 1 line
Thanks for the fix.
Thanks for your positive feedback.
Quoted 1 line
I was on vacation - but now seeing all the analysis made here,
I assume that special communication settings could trigger corresponding consequences for the discussed source code adjustment.
Quoted 1 line
if "ch" can't be NULL then please go ahead and remove the check =)
Would you dare to convert this request into a concrete patch?
Regards,
Markus
Re: jsm_tty: Deletion of a null pointer check in two functions?
Quoted 7 lines · SF Markus Elfring
Quoted 1 line
Thanks for the fix.
Thanks for your positive feedback.
Quoted 1 line
I was on vacation - but now seeing all the analysis made here,
Quoted 7 lines
I assume that special communication settings could trigger corresponding consequences for the discussed source code adjustment.
Quoted 1 line
if "ch" can't be NULL then please go ahead and remove the check =)
Would you dare to convert this request into a concrete patch?
For me, it's OK if you send the patch or I can do it myself. It's a minor patch...but it's correct the way I see it.
So, what do you prefer? Send it yourself, or want me to send it with your sign-off too? (since was your idea).
Thanks,
Guilherme
Quoted 4 lines
Regards,
Markus
Re: jsm_tty: Deletion of a null pointer check in two functions?
Quoted 1 line
So, what do you prefer? Send it yourself,
I became concerned that “my patch” would not get picked up because of Greg's communication settings (for my initial messages when they do not get resent by other contributors).
Quoted 1 line
or want me to send it with your sign-off too? (since was your idea).
I would prefer this variant because I assume that the chances for integration are higher for the discussed small source code adjustment.
I guess that the tag “Suggested-by” would be sufficient in this case.
Regards,
Markus