* [PATCH] arch: cris: arch-v32: drivers: axisflashmap.c: Cleaning up inconsistent NULL checks
@ 2014-05-22 22:00 Rickard Strandqvist
2014-05-23 7:00 ` Jesper Nilsson
0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-05-22 22:00 UTC (permalink / raw)
To: Mikael Starvik, Jesper Nilsson
Cc: Rickard Strandqvist, Al Viro, linux-cris-kernel, linux-kernel
Cleaning up inconsistent NULL checks.
There is otherwise a risk of a possible null pointer dereference.
Was largely found by using a static code analysis program called cppcheck.
Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
arch/cris/arch-v32/drivers/axisflashmap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/cris/arch-v32/drivers/axisflashmap.c b/arch/cris/arch-v32/drivers/axisflashmap.c
index 28dd771..e359cd7 100644
--- a/arch/cris/arch-v32/drivers/axisflashmap.c
+++ b/arch/cris/arch-v32/drivers/axisflashmap.c
@@ -487,7 +487,7 @@ static int __init init_axis_flash(void)
axis_partitions[pidx].offset = offset + ptable->offset;
#ifdef CONFIG_ETRAX_NANDFLASH
- if (main_mtd->type == MTD_NANDFLASH) {
+ if (main_mtd && main_mtd->type == MTD_NANDFLASH) {
axis_partitions[pidx].size =
(((ptable+1)->offset ==
PARTITIONTABLE_END_MARKER) ?
--
1.7.10.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] arch: cris: arch-v32: drivers: axisflashmap.c: Cleaning up inconsistent NULL checks
2014-05-22 22:00 [PATCH] arch: cris: arch-v32: drivers: axisflashmap.c: Cleaning up inconsistent NULL checks Rickard Strandqvist
@ 2014-05-23 7:00 ` Jesper Nilsson
2014-05-23 16:40 ` Rickard Strandqvist
0 siblings, 1 reply; 4+ messages in thread
From: Jesper Nilsson @ 2014-05-23 7:00 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Mikael Starvik, Jesper Nilsson, Al Viro, linux-cris-kernel,
linux-kernel@vger.kernel.org
On Fri, May 23, 2014 at 12:00:09AM +0200, Rickard Strandqvist wrote:
> Cleaning up inconsistent NULL checks.
> There is otherwise a risk of a possible null pointer dereference.
>
> Was largely found by using a static code analysis program called cppcheck.
... and is a false positive.
We can't enter this if-block unless ptable_head is set,
which is only set if main_mtd is set.
It might be useful to add it anyways, but there's a refactoring
needed for the axisflashmaps, so I'll keep it for then.
/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper.nilsson@axis.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arch: cris: arch-v32: drivers: axisflashmap.c: Cleaning up inconsistent NULL checks
2014-05-23 7:00 ` Jesper Nilsson
@ 2014-05-23 16:40 ` Rickard Strandqvist
2014-05-26 8:09 ` Jesper Nilsson
0 siblings, 1 reply; 4+ messages in thread
From: Rickard Strandqvist @ 2014-05-23 16:40 UTC (permalink / raw)
To: Jesper Nilsson
Cc: Mikael Starvik, Jesper Nilsson, Al Viro, linux-cris-kernel,
linux-kernel@vger.kernel.org
Hej Jesper!
But in several other place in the feature ensures that main_mtd is not NULL.
(That's what cppcheck base their misjudgment on too)
Then all these checks are unnecessary?
You should know, looks like you've written most of the code in 2007 :)
Best regards
Rickard Strandqvist
2014-05-23 9:00 GMT+02:00 Jesper Nilsson <jesper.nilsson@axis.com>:
> On Fri, May 23, 2014 at 12:00:09AM +0200, Rickard Strandqvist wrote:
>> Cleaning up inconsistent NULL checks.
>> There is otherwise a risk of a possible null pointer dereference.
>>
>> Was largely found by using a static code analysis program called cppcheck.
>
> ... and is a false positive.
>
> We can't enter this if-block unless ptable_head is set,
> which is only set if main_mtd is set.
>
> It might be useful to add it anyways, but there's a refactoring
> needed for the axisflashmaps, so I'll keep it for then.
>
> /^JN - Jesper Nilsson
> --
> Jesper Nilsson -- jesper.nilsson@axis.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] arch: cris: arch-v32: drivers: axisflashmap.c: Cleaning up inconsistent NULL checks
2014-05-23 16:40 ` Rickard Strandqvist
@ 2014-05-26 8:09 ` Jesper Nilsson
0 siblings, 0 replies; 4+ messages in thread
From: Jesper Nilsson @ 2014-05-26 8:09 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Jesper Nilsson, Mikael Starvik, Al Viro, linux-cris-kernel,
linux-kernel@vger.kernel.org
On Fri, May 23, 2014 at 06:40:17PM +0200, Rickard Strandqvist wrote:
> Hej Jesper!
Tjo!
> But in several other place in the feature ensures that main_mtd is not NULL.
> (That's what cppcheck base their misjudgment on too)
>
> Then all these checks are unnecessary?
No, it is still necessary to check for NULL, however as I wrote in my reply,
we do check for ptable_head, which is only set if main_mtd is set.
> You should know, looks like you've written most of the code in 2007 :)
>
> Best regards
> Rickard Strandqvist
/Jesper
> 2014-05-23 9:00 GMT+02:00 Jesper Nilsson <jesper.nilsson@axis.com>:
> > On Fri, May 23, 2014 at 12:00:09AM +0200, Rickard Strandqvist wrote:
> >> Cleaning up inconsistent NULL checks.
> >> There is otherwise a risk of a possible null pointer dereference.
> >>
> >> Was largely found by using a static code analysis program called cppcheck.
> >
> > ... and is a false positive.
> >
> > We can't enter this if-block unless ptable_head is set,
> > which is only set if main_mtd is set.
> >
> > It might be useful to add it anyways, but there's a refactoring
> > needed for the axisflashmaps, so I'll keep it for then.
> >
> > /^JN - Jesper Nilsson
> > --
> > Jesper Nilsson -- jesper.nilsson@axis.com
/^JN - Jesper Nilsson
--
Jesper Nilsson -- jesper.nilsson@axis.com
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-05-26 8:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 22:00 [PATCH] arch: cris: arch-v32: drivers: axisflashmap.c: Cleaning up inconsistent NULL checks Rickard Strandqvist
2014-05-23 7:00 ` Jesper Nilsson
2014-05-23 16:40 ` Rickard Strandqvist
2014-05-26 8:09 ` Jesper Nilsson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox