All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] ALSA: hdsp: silence and underflow warning
@ 2015-08-21 11:25 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-08-21 11:25 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel, kernel-janitors

I believe this probably cannot happen, as the code suggests.  There
would have to be an kcontrol->index.id which was zero, otherwise this
would be prevented in snd_ctl_find_id().  But snd_BUG_ON() is just a
WARN() or a no-op so static checkers complain that we keep on going with
a negative offset.  Let's just handle the error as well as printing
a warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index c19e021..468a95c 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -2806,7 +2806,8 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
 	struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
 	offset = ucontrol->id.index - 1;
-	snd_BUG_ON(offset < 0);
+	if (snd_BUG_ON(offset < 0))
+		return -EINVAL;
 
 	switch (hdsp->io_type) {
 	case Digiface:

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

* [patch] ALSA: hdsp: silence and underflow warning
@ 2015-08-21 11:25 ` Dan Carpenter
  0 siblings, 0 replies; 4+ messages in thread
From: Dan Carpenter @ 2015-08-21 11:25 UTC (permalink / raw)
  To: Jaroslav Kysela; +Cc: Takashi Iwai, alsa-devel, kernel-janitors

I believe this probably cannot happen, as the code suggests.  There
would have to be an kcontrol->index.id which was zero, otherwise this
would be prevented in snd_ctl_find_id().  But snd_BUG_ON() is just a
WARN() or a no-op so static checkers complain that we keep on going with
a negative offset.  Let's just handle the error as well as printing
a warning.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
index c19e021..468a95c 100644
--- a/sound/pci/rme9652/hdsp.c
+++ b/sound/pci/rme9652/hdsp.c
@@ -2806,7 +2806,8 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
 	struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
 
 	offset = ucontrol->id.index - 1;
-	snd_BUG_ON(offset < 0);
+	if (snd_BUG_ON(offset < 0))
+		return -EINVAL;
 
 	switch (hdsp->io_type) {
 	case Digiface:

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

* Re: [patch] ALSA: hdsp: silence and underflow warning
  2015-08-21 11:25 ` Dan Carpenter
@ 2015-08-21 12:13   ` Takashi Iwai
  -1 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2015-08-21 12:13 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Jaroslav Kysela, alsa-devel, kernel-janitors

On Fri, 21 Aug 2015 13:25:34 +0200,
Dan Carpenter wrote:
> 
> I believe this probably cannot happen, as the code suggests.  There
> would have to be an kcontrol->index.id which was zero, otherwise this
> would be prevented in snd_ctl_find_id().  But snd_BUG_ON() is just a
> WARN() or a no-op so static checkers complain that we keep on going with
> a negative offset.  Let's just handle the error as well as printing
> a warning.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks.


Takashi

> 
> diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
> index c19e021..468a95c 100644
> --- a/sound/pci/rme9652/hdsp.c
> +++ b/sound/pci/rme9652/hdsp.c
> @@ -2806,7 +2806,8 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
>  	struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
>  
>  	offset = ucontrol->id.index - 1;
> -	snd_BUG_ON(offset < 0);
> +	if (snd_BUG_ON(offset < 0))
> +		return -EINVAL;
>  
>  	switch (hdsp->io_type) {
>  	case Digiface:
> 

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

* Re: [patch] ALSA: hdsp: silence and underflow warning
@ 2015-08-21 12:13   ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2015-08-21 12:13 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Jaroslav Kysela, alsa-devel, kernel-janitors

On Fri, 21 Aug 2015 13:25:34 +0200,
Dan Carpenter wrote:
> 
> I believe this probably cannot happen, as the code suggests.  There
> would have to be an kcontrol->index.id which was zero, otherwise this
> would be prevented in snd_ctl_find_id().  But snd_BUG_ON() is just a
> WARN() or a no-op so static checkers complain that we keep on going with
> a negative offset.  Let's just handle the error as well as printing
> a warning.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks.


Takashi

> 
> diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c
> index c19e021..468a95c 100644
> --- a/sound/pci/rme9652/hdsp.c
> +++ b/sound/pci/rme9652/hdsp.c
> @@ -2806,7 +2806,8 @@ static int snd_hdsp_get_adat_sync_check(struct snd_kcontrol *kcontrol, struct sn
>  	struct hdsp *hdsp = snd_kcontrol_chip(kcontrol);
>  
>  	offset = ucontrol->id.index - 1;
> -	snd_BUG_ON(offset < 0);
> +	if (snd_BUG_ON(offset < 0))
> +		return -EINVAL;
>  
>  	switch (hdsp->io_type) {
>  	case Digiface:
> 

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

end of thread, other threads:[~2015-08-21 12:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-21 11:25 [patch] ALSA: hdsp: silence and underflow warning Dan Carpenter
2015-08-21 11:25 ` Dan Carpenter
2015-08-21 12:13 ` Takashi Iwai
2015-08-21 12:13   ` Takashi Iwai

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.