alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: alsa-devel@alsa-project.org
Subject: hdsp: potential oops in snd_hdsp_info_pref_sync_ref()
Date: Fri, 6 Jan 2012 16:59:57 +0300	[thread overview]
Message-ID: <20120106135957.GA4316@elgon.mountain> (raw)

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

             reply	other threads:[~2012-01-06 14:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-06 13:59 Dan Carpenter [this message]
2012-01-09 17:29 ` hdsp: potential oops in snd_hdsp_info_pref_sync_ref() Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120106135957.GA4316@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).