netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 0/1] Parfait changes
@ 2018-02-15 20:26 Joe Moriarty
  2018-02-15 20:27 ` [PATCH v1 1/1] drivers: isdn: NULL pointer dereference [null-pointer-deref] (CWE 476) problem Joe Moriarty
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Moriarty @ 2018-02-15 20:26 UTC (permalink / raw)
  To: davem; +Cc: netdev

The following patch(s) are bugs found by the static compiler
'Parfait'.  Care was taken to make sure false positive results
were removed from this patchset.

Parfait Overview
================

https://labs.oracle.com/pls/apex/f?p=labs:49:::::P49_PROJECT_ID:13

v1:
Initial release

Joe Moriarty (1):
  drivers: isdn: NULL pointer dereference [null-pointer-deref] (CWE 476)
    problem

 drivers/isdn/mISDN/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

-- 
2.15.0

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

* [PATCH v1 1/1] drivers: isdn: NULL pointer dereference [null-pointer-deref] (CWE 476) problem
  2018-02-15 20:26 [PATCH v1 0/1] Parfait changes Joe Moriarty
@ 2018-02-15 20:27 ` Joe Moriarty
  2018-02-16 21:11   ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Moriarty @ 2018-02-15 20:27 UTC (permalink / raw)
  To: davem; +Cc: netdev

The Parfait (version 2.1.0) static code analysis tool found the
following NULL pointer dereference problem.

- drivers/isdn/mISDN/core.c
function channelmap_show() does not check the returned mdev
variable from dev_to_mISDN() for NULL.  Added the check for
NULL, which results in a value of 0 being returned.

Signed-off-by: Joe Moriarty <joe.moriarty@oracle.com>
Reviewed-by: Jonathan Helman <jonathan.helman@oracle.com>
---
 drivers/isdn/mISDN/core.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/isdn/mISDN/core.c b/drivers/isdn/mISDN/core.c
index faf505462a4f..aec7e2706109 100644
--- a/drivers/isdn/mISDN/core.c
+++ b/drivers/isdn/mISDN/core.c
@@ -129,8 +129,10 @@ static ssize_t channelmap_show(struct device *dev,
 	char *bp = buf;
 	int i;
 
-	for (i = 0; i <= mdev->nrbchan; i++)
-		*bp++ = test_channelmap(i, mdev->channelmap) ? '1' : '0';
+	if (mdev)
+		for (i = 0; i <= mdev->nrbchan; i++)
+			*bp++ = test_channelmap(i, mdev->channelmap) ?
+				'1' : '0';
 
 	return bp - buf;
 }
-- 
2.15.0

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

* Re: [PATCH v1 1/1] drivers: isdn: NULL pointer dereference [null-pointer-deref] (CWE 476) problem
  2018-02-15 20:27 ` [PATCH v1 1/1] drivers: isdn: NULL pointer dereference [null-pointer-deref] (CWE 476) problem Joe Moriarty
@ 2018-02-16 21:11   ` David Miller
  2018-02-20 13:47     ` Joe Moriarty
  0 siblings, 1 reply; 4+ messages in thread
From: David Miller @ 2018-02-16 21:11 UTC (permalink / raw)
  To: joe.moriarty; +Cc: netdev

From: Joe Moriarty <joe.moriarty@oracle.com>
Date: Thu, 15 Feb 2018 15:27:00 -0500

> The Parfait (version 2.1.0) static code analysis tool found the
> following NULL pointer dereference problem.
> 
> - drivers/isdn/mISDN/core.c
> function channelmap_show() does not check the returned mdev
> variable from dev_to_mISDN() for NULL.  Added the check for
> NULL, which results in a value of 0 being returned.
> 
> Signed-off-by: Joe Moriarty <joe.moriarty@oracle.com>
> Reviewed-by: Jonathan Helman <jonathan.helman@oracle.com>

Since the lifetime for the sysfs files for these devices is strictly
smaller than the lifetime of the 'dev' object and it's driver data,
it is not possible for mdev to be NULL in this situation.

I understand what the static checker is trying to do, but within
context this lack of a NULL check is legitimate.

I'm not applying this, sorry.

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

* Re: [PATCH v1 1/1] drivers: isdn: NULL pointer dereference [null-pointer-deref] (CWE 476) problem
  2018-02-16 21:11   ` David Miller
@ 2018-02-20 13:47     ` Joe Moriarty
  0 siblings, 0 replies; 4+ messages in thread
From: Joe Moriarty @ 2018-02-20 13:47 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

On 2/16/2018 4:11 PM, David Miller wrote:
> From: Joe Moriarty <joe.moriarty@oracle.com>
> Date: Thu, 15 Feb 2018 15:27:00 -0500
> 
>> The Parfait (version 2.1.0) static code analysis tool found the
>> following NULL pointer dereference problem.
>>
>> - drivers/isdn/mISDN/core.c
>> function channelmap_show() does not check the returned mdev
>> variable from dev_to_mISDN() for NULL.  Added the check for
>> NULL, which results in a value of 0 being returned.
>>
>> Signed-off-by: Joe Moriarty <joe.moriarty@oracle.com>
>> Reviewed-by: Jonathan Helman <jonathan.helman@oracle.com>
> 
> Since the lifetime for the sysfs files for these devices is strictly
> smaller than the lifetime of the 'dev' object and it's driver data,
> it is not possible for mdev to be NULL in this situation.
> 
> I understand what the static checker is trying to do, but within
> context this lack of a NULL check is legitimate.
> 
> I'm not applying this, sorry.
> 
Thanks for the review David and there is no reason to be sorry.  I'll 
will mark this as a false positive result from our static checker.

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

end of thread, other threads:[~2018-02-20 13:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-02-15 20:26 [PATCH v1 0/1] Parfait changes Joe Moriarty
2018-02-15 20:27 ` [PATCH v1 1/1] drivers: isdn: NULL pointer dereference [null-pointer-deref] (CWE 476) problem Joe Moriarty
2018-02-16 21:11   ` David Miller
2018-02-20 13:47     ` Joe Moriarty

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).