* [PATCH] arch: metag: mm: hugetlbpage.c: Cleaning up inconsistent NULL checks
@ 2014-05-22 22:01 ` Rickard Strandqvist
0 siblings, 0 replies; 5+ messages in thread
From: Rickard Strandqvist @ 2014-05-22 22:01 UTC (permalink / raw)
To: James Hogan, Rickard Strandqvist
Cc: Andrew Morton, Naoya Horiguchi,
linux-metag-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
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-IW2WV5XWFqGZkjO+N0TKoMugMpMbD5Xr@public.gmane.org>
---
arch/metag/mm/hugetlbpage.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
index 0424315..3f8d5cd 100644
--- a/arch/metag/mm/hugetlbpage.c
+++ b/arch/metag/mm/hugetlbpage.c
@@ -188,7 +188,8 @@ new_search:
}
}
after_huge = 0;
- addr = ALIGN_HUGEPT(vma->vm_end);
+ if (vma)
+ addr = ALIGN_HUGEPT(vma->vm_end);
}
}
#endif
--
1.7.10.4
--
To unsubscribe from this list: send the line "unsubscribe linux-metag" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] arch: metag: mm: hugetlbpage.c: Cleaning up inconsistent NULL checks
@ 2014-05-22 22:01 ` Rickard Strandqvist
0 siblings, 0 replies; 5+ messages in thread
From: Rickard Strandqvist @ 2014-05-22 22:01 UTC (permalink / raw)
To: James Hogan, Rickard Strandqvist
Cc: Andrew Morton, Naoya Horiguchi, linux-metag, 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/metag/mm/hugetlbpage.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
index 0424315..3f8d5cd 100644
--- a/arch/metag/mm/hugetlbpage.c
+++ b/arch/metag/mm/hugetlbpage.c
@@ -188,7 +188,8 @@ new_search:
}
}
after_huge = 0;
- addr = ALIGN_HUGEPT(vma->vm_end);
+ if (vma)
+ addr = ALIGN_HUGEPT(vma->vm_end);
}
}
#endif
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] arch: metag: mm: hugetlbpage.c: Cleaning up inconsistent NULL checks
2014-05-22 22:01 ` Rickard Strandqvist
@ 2014-05-28 10:03 ` James Hogan
-1 siblings, 0 replies; 5+ messages in thread
From: James Hogan @ 2014-05-28 10:03 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Andrew Morton, Naoya Horiguchi, linux-metag, linux-kernel, Paul
Hi Rickard,
On 22/05/14 23:01, 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.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> arch/metag/mm/hugetlbpage.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
> index 0424315..3f8d5cd 100644
> --- a/arch/metag/mm/hugetlbpage.c
> +++ b/arch/metag/mm/hugetlbpage.c
> @@ -188,7 +188,8 @@ new_search:
> }
> }
> after_huge = 0;
> - addr = ALIGN_HUGEPT(vma->vm_end);
> + if (vma)
> + addr = ALIGN_HUGEPT(vma->vm_end);
> }
> }
> #endif
>
I don't think this is a correct fix.
If !vma && !after_huge the first if block in the loop will match and the
function will return 0.
If !vma && after_huge the 3rd if block in the loop will match and the
function will return addr.
So removing the vma condition on the final if block in the loop would
probably make sense instead. Does that satisfy cppcheck?
Cheers
James
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] arch: metag: mm: hugetlbpage.c: Cleaning up inconsistent NULL checks
@ 2014-05-28 10:03 ` James Hogan
0 siblings, 0 replies; 5+ messages in thread
From: James Hogan @ 2014-05-28 10:03 UTC (permalink / raw)
To: Rickard Strandqvist
Cc: Andrew Morton, Naoya Horiguchi, linux-metag, linux-kernel, Paul
Hi Rickard,
On 22/05/14 23:01, 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.
>
> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
> arch/metag/mm/hugetlbpage.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
> index 0424315..3f8d5cd 100644
> --- a/arch/metag/mm/hugetlbpage.c
> +++ b/arch/metag/mm/hugetlbpage.c
> @@ -188,7 +188,8 @@ new_search:
> }
> }
> after_huge = 0;
> - addr = ALIGN_HUGEPT(vma->vm_end);
> + if (vma)
> + addr = ALIGN_HUGEPT(vma->vm_end);
> }
> }
> #endif
>
I don't think this is a correct fix.
If !vma && !after_huge the first if block in the loop will match and the
function will return 0.
If !vma && after_huge the 3rd if block in the loop will match and the
function will return addr.
So removing the vma condition on the final if block in the loop would
probably make sense instead. Does that satisfy cppcheck?
Cheers
James
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] arch: metag: mm: hugetlbpage.c: Cleaning up inconsistent NULL checks
2014-05-28 10:03 ` James Hogan
(?)
@ 2014-05-29 22:45 ` Rickard Strandqvist
-1 siblings, 0 replies; 5+ messages in thread
From: Rickard Strandqvist @ 2014-05-29 22:45 UTC (permalink / raw)
To: James Hogan
Cc: Andrew Morton, Naoya Horiguchi, linux-metag,
linux-kernel@vger.kernel.org, Paul
Hi
First, I do not think we'll adapt the code as a static code checking to work!
This must be resolved by other means.
But yes, it is control where that gets cppcheck to react. And it is
then also an unnecessary control. So then I guess it's ok to remove
it.
I resend a patch, with it removed.
Best regards
Rickard Strandqvist
2014-05-28 12:03 GMT+02:00 James Hogan <james.hogan@imgtec.com>:
> Hi Rickard,
>
> On 22/05/14 23:01, 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.
>>
>> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
>> ---
>> arch/metag/mm/hugetlbpage.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
>> index 0424315..3f8d5cd 100644
>> --- a/arch/metag/mm/hugetlbpage.c
>> +++ b/arch/metag/mm/hugetlbpage.c
>> @@ -188,7 +188,8 @@ new_search:
>> }
>> }
>> after_huge = 0;
>> - addr = ALIGN_HUGEPT(vma->vm_end);
>> + if (vma)
>> + addr = ALIGN_HUGEPT(vma->vm_end);
>> }
>> }
>> #endif
>>
>
> I don't think this is a correct fix.
>
> If !vma && !after_huge the first if block in the loop will match and the
> function will return 0.
> If !vma && after_huge the 3rd if block in the loop will match and the
> function will return addr.
>
> So removing the vma condition on the final if block in the loop would
> probably make sense instead. Does that satisfy cppcheck?
>
> Cheers
> James
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-05-29 22:45 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-22 22:01 [PATCH] arch: metag: mm: hugetlbpage.c: Cleaning up inconsistent NULL checks Rickard Strandqvist
2014-05-22 22:01 ` Rickard Strandqvist
2014-05-28 10:03 ` James Hogan
2014-05-28 10:03 ` James Hogan
2014-05-29 22:45 ` Rickard Strandqvist
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.