linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel/debug/kdb/kdb_bp.c: fix argument range check
@ 2014-07-18 17:40 Andrey Utkin
  2014-07-22  7:53 ` Dan Carpenter
  0 siblings, 1 reply; 2+ messages in thread
From: Andrey Utkin @ 2014-07-18 17:40 UTC (permalink / raw)
  To: linux-kernel, kernel-janitors, kgdb-bugreport
  Cc: dcb314, jason.wessel, wharms, Andrey Utkin

Dropped negativity check; enhanced upper limit check as proposed by
Walter Harms <wharms@bfs.de>

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=80591
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Andrey Utkin <andrey.krieger.utkin@gmail.com>
---
 kernel/debug/kdb/kdb_bp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/debug/kdb/kdb_bp.c b/kernel/debug/kdb/kdb_bp.c
index 70a5046..371150f 100644
--- a/kernel/debug/kdb/kdb_bp.c
+++ b/kernel/debug/kdb/kdb_bp.c
@@ -39,7 +39,7 @@ static char *kdb_rwtypes[] = {
 
 static char *kdb_bptype(kdb_bp_t *bp)
 {
-	if (bp->bp_type < 0 || bp->bp_type > 4)
+	if (bp->bp_type >= ARRAY_SIZE(kdb_rwtypes))
 		return "";
 
 	return kdb_rwtypes[bp->bp_type];
-- 
1.8.5.5


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

* Re: [PATCH] kernel/debug/kdb/kdb_bp.c: fix argument range check
  2014-07-18 17:40 [PATCH] kernel/debug/kdb/kdb_bp.c: fix argument range check Andrey Utkin
@ 2014-07-22  7:53 ` Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2014-07-22  7:53 UTC (permalink / raw)
  To: Andrey Utkin
  Cc: linux-kernel, kernel-janitors, kgdb-bugreport, dcb314,
	jason.wessel, wharms

On Fri, Jul 18, 2014 at 08:40:24PM +0300, Andrey Utkin wrote:
> Dropped negativity check; enhanced upper limit check as proposed by
> Walter Harms <wharms@bfs.de>
> 
> Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=80591
> Reported-by: David Binderman <dcb314@hotmail.com>
> Signed-off-by: Andrey Utkin <andrey.krieger.utkin@gmail.com>
> ---
>  kernel/debug/kdb/kdb_bp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/debug/kdb/kdb_bp.c b/kernel/debug/kdb/kdb_bp.c
> index 70a5046..371150f 100644
> --- a/kernel/debug/kdb/kdb_bp.c
> +++ b/kernel/debug/kdb/kdb_bp.c
> @@ -39,7 +39,7 @@ static char *kdb_rwtypes[] = {
>  
>  static char *kdb_bptype(kdb_bp_t *bp)
>  {
> -	if (bp->bp_type < 0 || bp->bp_type > 4)
> +	if (bp->bp_type >= ARRAY_SIZE(kdb_rwtypes))
>  		return "";

I like this version of the patch because it silences the static checker
warning like the first one does but it also makes the code more
readable.

regards,
dan carpenter


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

end of thread, other threads:[~2014-07-22  7:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-18 17:40 [PATCH] kernel/debug/kdb/kdb_bp.c: fix argument range check Andrey Utkin
2014-07-22  7:53 ` Dan Carpenter

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