Skip to contentSkip to conversation

Staging: vc04_services: Fix WARN_ON instead of BUG_ON

PATCH In review janani-sankarababu 3 participants 3 messages Jul 31, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: vc04_services: Fix WARN_ON instead of BUG_ON

This patch is to replace the use of BUG_ON macro with WARN_ON inorder to prevent the crashing of the kernel.

---
 drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +1 -1
index f484bb0..30bc246 100644
@@ -91,7 +91,7 @@ static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol,
 	if (mutex_lock_interruptible(&chip->audio_mutex))
 		return -EINTR;
 
-	BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
+	WARN_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
 
 	if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
 		ucontrol->value.integer.value[0] = chip2alsa(chip->volume);
Signature · 1 line
1.9.1
#1 lore raw

Am 31.07.2017 um 09:14 schrieb janani-sankarababu:

Quoted 2 lines

This patch is to replace the use of BUG_ON macro with WARN_ON inorder to prevent the crashing of the kernel.

Unfortunately it isn't always that simple. checkpatch isn't smart. It's preferred to handle error cases instead of flooding the kernel log.

Quoted 11 lines
---
 drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +0 -0
index f484bb0..30bc246 100644

drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol, · line 94

Quoted 5 lines
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +1 -1
@@ -91,7 +91,7 @@ static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol,
 	if (mutex_lock_interruptible(&chip->audio_mutex))
 		return -EINTR;
 
-	BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
+	WARN_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));

The complete logic seems strange to me and the statement before didn't even check for chip.

Regards
Stefan

Quoted 3 lines
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +0 -0
 	if (kcontrol->private_value == PCM_PLAYBACK_VOLUME)
 		ucontrol->value.integer.value[0] = chip2alsa(chip->volume);
#2 lore raw
In reply to janani-sankarababu
Quoted 13 lines · janani-sankarababu

This patch is to replace the use of BUG_ON macro with WARN_ON inorder to prevent the crashing of the kernel.

---
 drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +0 -0
index f484bb0..30bc246 100644

drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol, · line 91

Quoted 1 line
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +0 -0
@@ -91,7 +91,7 @@ static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol,
 	if (mutex_lock_interruptible(&chip->audio_mutex))
                                      ^^^^^^

We dereference chip here.

drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c static int snd_bcm2835_ctl_get(struct snd_kcontrol *kcontrol, · line 94

Quoted 4 lines
drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c +1 -1
 		return -EINTR;
 
-	BUG_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
+	WARN_ON(!chip && !(chip->avail_substreams & AVAIL_SUBSTREAMS_MASK));
                ^^^^^

Too late.

regards,
dan carpenter