linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bcm2048: Fix checkpatch checks
@ 2017-02-18  3:52 Man Choy
  2017-02-27  8:21 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 3+ messages in thread
From: Man Choy @ 2017-02-18  3:52 UTC (permalink / raw)
  To: bhumirks
  Cc: Man Choy, Mauro Carvalho Chehab, Greg Kroah-Hartman, linux-media,
	devel, linux-kernel

Fix following checks:

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)
+       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
                     ^

CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
+       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);

CHECK: spaces preferred around that '+' (ctx:VxV)
+       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
                     ^
---
 drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
index 37bd439..d5ee279 100644
--- a/drivers/staging/media/bcm2048/radio-bcm2048.c
+++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
@@ -1534,7 +1534,7 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i,
 	if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
 		return 0;
 
-	BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
+	WARN_ON((index + 2) >= BCM2048_MAX_RDS_RT);
 
 	if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
 		BCM2048_RDS_BLOCK_C) {
@@ -1557,7 +1557,7 @@ static void bcm2048_parse_rt_match_d(struct bcm2048_device *bdev, int i,
 	if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
 		return;
 
-	BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
+	WARN_ON((index + 4) >= BCM2048_MAX_RDS_RT);
 
 	if ((bdev->rds_info.radio_text[i] & BCM2048_RDS_BLOCK_MASK) ==
 	    BCM2048_RDS_BLOCK_D)
-- 
2.7.4

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

* Re: [PATCH] bcm2048: Fix checkpatch checks
  2017-02-18  3:52 [PATCH] bcm2048: Fix checkpatch checks Man Choy
@ 2017-02-27  8:21 ` Greg Kroah-Hartman
  2017-02-28  1:07   ` Man Choy
  0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2017-02-27  8:21 UTC (permalink / raw)
  To: Man Choy
  Cc: bhumirks, Mauro Carvalho Chehab, linux-media, devel, linux-kernel

On Sat, Feb 18, 2017 at 11:52:37AM +0800, Man Choy wrote:
> Fix following checks:
> 
> CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
> +       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
> 
> CHECK: spaces preferred around that '+' (ctx:VxV)
> +       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
>                      ^
> 
> CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
> +       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
> 
> CHECK: spaces preferred around that '+' (ctx:VxV)
> +       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
>                      ^
> ---
>  drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
> index 37bd439..d5ee279 100644
> --- a/drivers/staging/media/bcm2048/radio-bcm2048.c
> +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
> @@ -1534,7 +1534,7 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i,
>  	if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
>  		return 0;
>  
> -	BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
> +	WARN_ON((index + 2) >= BCM2048_MAX_RDS_RT);

Ick, no to all of these!  What happens if this is true, the code will
crash, right?  You have to properly recover from this, don't just throw
the message out to userspace and then keep on going.

You can't just do a search/replace for this, otherwise it would have
been done already :)

thanks,

greg k-h

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

* Re: [PATCH] bcm2048: Fix checkpatch checks
  2017-02-27  8:21 ` Greg Kroah-Hartman
@ 2017-02-28  1:07   ` Man Choy
  0 siblings, 0 replies; 3+ messages in thread
From: Man Choy @ 2017-02-28  1:07 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Bhumika Goyal, Mauro Carvalho Chehab, linux-media, devel, linux-kernel

On Mon, Feb 27, 2017 at 4:21 PM, Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
> On Sat, Feb 18, 2017 at 11:52:37AM +0800, Man Choy wrote:
>> Fix following checks:
>>
>> CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
>> +       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
>>
>> CHECK: spaces preferred around that '+' (ctx:VxV)
>> +       BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
>>                      ^
>>
>> CHECK: Avoid crashing the kernel - try using WARN_ON & recovery code rather than BUG() or BUG_ON()
>> +       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
>>
>> CHECK: spaces preferred around that '+' (ctx:VxV)
>> +       BUG_ON((index+4) >= BCM2048_MAX_RDS_RT);
>>                      ^
>> ---
>>  drivers/staging/media/bcm2048/radio-bcm2048.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/staging/media/bcm2048/radio-bcm2048.c b/drivers/staging/media/bcm2048/radio-bcm2048.c
>> index 37bd439..d5ee279 100644
>> --- a/drivers/staging/media/bcm2048/radio-bcm2048.c
>> +++ b/drivers/staging/media/bcm2048/radio-bcm2048.c
>> @@ -1534,7 +1534,7 @@ static int bcm2048_parse_rt_match_c(struct bcm2048_device *bdev, int i,
>>       if (crc == BCM2048_RDS_CRC_UNRECOVARABLE)
>>               return 0;
>>
>> -     BUG_ON((index+2) >= BCM2048_MAX_RDS_RT);
>> +     WARN_ON((index + 2) >= BCM2048_MAX_RDS_RT);
>
> Ick, no to all of these!  What happens if this is true, the code will
> crash, right?  You have to properly recover from this, don't just throw
> the message out to userspace and then keep on going.
>
> You can't just do a search/replace for this, otherwise it would have
> been done already :)
>
> thanks,
>
> greg k-h

Okay, noted. Thanks.

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

end of thread, other threads:[~2017-02-28  1:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-18  3:52 [PATCH] bcm2048: Fix checkpatch checks Man Choy
2017-02-27  8:21 ` Greg Kroah-Hartman
2017-02-28  1:07   ` Man Choy

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