alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* hdsp: potential oops in snd_hdsp_info_pref_sync_ref()
@ 2012-01-06 13:59 Dan Carpenter
  2012-01-09 17:29 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2012-01-06 13:59 UTC (permalink / raw)
  To: alsa-devel

My static check complains that there is a potential oops here but I'm
not sure what the correct fix is.

sound/pci/rme9652/hdsp.c
  2631          switch (hdsp->io_type) {
  2632          case Digiface:
  2633          case H9652:
  2634                  uinfo->value.enumerated.items = 6;
  2635                  break;
  2636          case Multiface:
  2637                  uinfo->value.enumerated.items = 4;
  2638                  break;
  2639          case H9632:
  2640                  uinfo->value.enumerated.items = 3;
  2641                  break;
  2642          default:
  2643                  uinfo->value.enumerated.items = 0;
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
We set this to zero here.

  2644                  break;
  2645          }
  2646  
  2647          if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
enumerated.item is unsigned int so it's always greater or equal to zero.

  2648                  uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;

We set it to UINT_MAX here.

  2649          strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
                                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Reading UINT_MAX beyond the end of the array here will probably oops.

  2650          return 0;

There is a similar issue in snd_asihpi_cmode_info().

regards,
dan carpenter

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

* Re: hdsp: potential oops in snd_hdsp_info_pref_sync_ref()
  2012-01-06 13:59 hdsp: potential oops in snd_hdsp_info_pref_sync_ref() Dan Carpenter
@ 2012-01-09 17:29 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2012-01-09 17:29 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: alsa-devel

At Fri, 6 Jan 2012 16:59:57 +0300,
Dan Carpenter wrote:
> 
> My static check complains that there is a potential oops here but I'm
> not sure what the correct fix is.
> 
> sound/pci/rme9652/hdsp.c
>   2631          switch (hdsp->io_type) {
>   2632          case Digiface:
>   2633          case H9652:
>   2634                  uinfo->value.enumerated.items = 6;
>   2635                  break;
>   2636          case Multiface:
>   2637                  uinfo->value.enumerated.items = 4;
>   2638                  break;
>   2639          case H9632:
>   2640                  uinfo->value.enumerated.items = 3;
>   2641                  break;
>   2642          default:
>   2643                  uinfo->value.enumerated.items = 0;
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> We set this to zero here.
> 
>   2644                  break;
>   2645          }
>   2646  
>   2647          if (uinfo->value.enumerated.item >= uinfo->value.enumerated.items)
>                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> enumerated.item is unsigned int so it's always greater or equal to zero.
> 
>   2648                  uinfo->value.enumerated.item = uinfo->value.enumerated.items - 1;
> 
> We set it to UINT_MAX here.
> 
>   2649          strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
>                                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Reading UINT_MAX beyond the end of the array here will probably oops.
> 
>   2650          return 0;
> 
> There is a similar issue in snd_asihpi_cmode_info().

Right, this is an obvious bug.  The driver should return an error
immediately there.

I fixed them in the sound git tree now.

Thanks!


Takashi

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

end of thread, other threads:[~2012-01-09 17:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-06 13:59 hdsp: potential oops in snd_hdsp_info_pref_sync_ref() Dan Carpenter
2012-01-09 17:29 ` Takashi Iwai

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