All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference
@ 2015-01-29 18:46 Rickard Strandqvist
  2015-02-02 16:36 ` Sudip Mukherjee
  0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2015-01-29 18:46 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Kiran Padwal; +Cc: Rickard Strandqvist, devel, linux-kernel

Fix a possible null pointer dereference, there is
otherwise a risk of a possible null pointer dereference.

This was found using a static code analysis program called cppcheck

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 drivers/staging/gdm724x/gdm_tty.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
index 001348c..66b356e 100644
--- a/drivers/staging/gdm724x/gdm_tty.c
+++ b/drivers/staging/gdm724x/gdm_tty.c
@@ -145,7 +145,7 @@ static int gdm_tty_recv_complete(void *data,
 	struct gdm *gdm = tty_dev->gdm[index];
 
 	if (!GDM_TTY_READY(gdm)) {
-		if (complete == RECV_PACKET_PROCESS_COMPLETE)
+		if (gdm && complete == RECV_PACKET_PROCESS_COMPLETE)
 			gdm_tty_recv(gdm, gdm_tty_recv_complete);
 		return TO_HOST_PORT_CLOSE;
 	}
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference
  2015-01-29 18:46 [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference Rickard Strandqvist
@ 2015-02-02 16:36 ` Sudip Mukherjee
  2015-02-04 17:46   ` Rickard Strandqvist
  0 siblings, 1 reply; 4+ messages in thread
From: Sudip Mukherjee @ 2015-02-02 16:36 UTC (permalink / raw)
  To: Rickard Strandqvist; +Cc: Greg Kroah-Hartman, Kiran Padwal, devel, linux-kernel

On Thu, Jan 29, 2015 at 07:46:10PM +0100, Rickard Strandqvist wrote:
> Fix a possible null pointer dereference, there is
> otherwise a risk of a possible null pointer dereference.
> 
> This was found using a static code analysis program called cppcheck
> 
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  drivers/staging/gdm724x/gdm_tty.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> index 001348c..66b356e 100644
> --- a/drivers/staging/gdm724x/gdm_tty.c
> +++ b/drivers/staging/gdm724x/gdm_tty.c
> @@ -145,7 +145,7 @@ static int gdm_tty_recv_complete(void *data,
>  	struct gdm *gdm = tty_dev->gdm[index];
>  
>  	if (!GDM_TTY_READY(gdm)) {
> -		if (complete == RECV_PACKET_PROCESS_COMPLETE)
> +		if (gdm && complete == RECV_PACKET_PROCESS_COMPLETE)
GDM_TTY_READY() is already checking for gdm, there is no chance that gdm can be null at this point. so this additional check is not required.

regards
sudip
>  			gdm_tty_recv(gdm, gdm_tty_recv_complete);
>  		return TO_HOST_PORT_CLOSE;
>  	}
> -- 
> 1.7.10.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference
  2015-02-02 16:36 ` Sudip Mukherjee
@ 2015-02-04 17:46   ` Rickard Strandqvist
  2015-02-05 12:19     ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2015-02-04 17:46 UTC (permalink / raw)
  To: Sudip Mukherjee
  Cc: Greg Kroah-Hartman, Kiran Padwal, devel, Linux Kernel Mailing List

2015-02-02 17:36 GMT+01:00 Sudip Mukherjee <sudipm.mukherjee@gmail.com>:
> On Thu, Jan 29, 2015 at 07:46:10PM +0100, Rickard Strandqvist wrote:
>> Fix a possible null pointer dereference, there is
>> otherwise a risk of a possible null pointer dereference.
>>
>> This was found using a static code analysis program called cppcheck
>>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> ---
>>  drivers/staging/gdm724x/gdm_tty.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
>> index 001348c..66b356e 100644
>> --- a/drivers/staging/gdm724x/gdm_tty.c
>> +++ b/drivers/staging/gdm724x/gdm_tty.c
>> @@ -145,7 +145,7 @@ static int gdm_tty_recv_complete(void *data,
>>       struct gdm *gdm = tty_dev->gdm[index];
>>
>>       if (!GDM_TTY_READY(gdm)) {
>> -             if (complete == RECV_PACKET_PROCESS_COMPLETE)
>> +             if (gdm && complete == RECV_PACKET_PROCESS_COMPLETE)
> GDM_TTY_READY() is already checking for gdm, there is no chance that gdm can be null at this point. so this additional check is not required.
>
> regards
> sudip
>>                       gdm_tty_recv(gdm, gdm_tty_recv_complete);
>>               return TO_HOST_PORT_CLOSE;
>>       }
>> --
>> 1.7.10.4
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>> Please read the FAQ at  http://www.tux.org/lkml/


Hi Sudip

Yes, GDM_TTY_READY checks gdm, but this is a if(! )


Kind regards
Rickard Strandqvist

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference
  2015-02-04 17:46   ` Rickard Strandqvist
@ 2015-02-05 12:19     ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-02-05 12:19 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: Sudip Mukherjee, devel, Greg Kroah-Hartman, Kiran Padwal,
	Linux Kernel Mailing List

On Wed, Feb 04, 2015 at 06:46:34PM +0100, Rickard Strandqvist wrote:
> 2015-02-02 17:36 GMT+01:00 Sudip Mukherjee <sudipm.mukherjee@gmail.com>:
> > On Thu, Jan 29, 2015 at 07:46:10PM +0100, Rickard Strandqvist wrote:
> >> diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
> >> index 001348c..66b356e 100644
> >> --- a/drivers/staging/gdm724x/gdm_tty.c
> >> +++ b/drivers/staging/gdm724x/gdm_tty.c
> >> @@ -145,7 +145,7 @@ static int gdm_tty_recv_complete(void *data,
> >>       struct gdm *gdm = tty_dev->gdm[index];
> >>
> >>       if (!GDM_TTY_READY(gdm)) {
> >> -             if (complete == RECV_PACKET_PROCESS_COMPLETE)
> >> +             if (gdm && complete == RECV_PACKET_PROCESS_COMPLETE)
> > GDM_TTY_READY() is already checking for gdm, there is no chance that gdm can be null at this point. so this additional check is not required.
> >
> > regards
> > sudip
> >>                       gdm_tty_recv(gdm, gdm_tty_recv_complete);
> >>               return TO_HOST_PORT_CLOSE;
> >>       }
> 
> Hi Sudip
> 
> Yes, GDM_TTY_READY checks gdm, but this is a if(! )
> 

You're right.  But, by that same logic, we should also test
gdm->tty_dev.  So it looks like this:

	if (!GDM_TTY_READY(gdm))  {
		if (gdm && gdm->tty_dev && complete == RECV_PACKET_PROCESS_COMPLETE)
			gdm_tty_recv(gdm, gdm_tty_recv_complete);
		return TO_HOST_PORT_CLOSE;
	}

That is really sucky...  Garbage code like this is why kernel style
doesn't favour macros.  We should just open code GDM_TTY_READY() and
gdm_tty_recv() so that people can read the code.

I wonder if "gdm->tty_dev" is the same as the "tty_dev" parameter?

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-02-05 12:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-29 18:46 [PATCH] staging: gdm724x: gdm_tty: Fix for possible null pointer dereference Rickard Strandqvist
2015-02-02 16:36 ` Sudip Mukherjee
2015-02-04 17:46   ` Rickard Strandqvist
2015-02-05 12:19     ` Dan Carpenter

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.