All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
Cc: alsa-devel@alsa-project.org,
	Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Subject: Re: ASoC: rsnd: care DMA slave channel name for DT
Date: Tue, 10 Jun 2014 21:02:45 +0300	[thread overview]
Message-ID: <20140610180245.GA12361@mwanda> (raw)

Hello Kuninori Morimoto,

The patch 199e7688bdf7: "ASoC: rsnd: care DMA slave channel name for
DT" from May 22, 2014, leads to the following static checker warning:

	sound/soc/sh/rcar/core.c:318 rsnd_dma_of_name()
	error: buffer overflow 'mod' 4 <= 4

sound/soc/sh/rcar/core.c
   278          struct rsnd_mod *mod[MOD_MAX];
   279          struct rsnd_mod *src_mod, *dst_mod;
   280          int i, index;
   281  
   282  
   283          for (i = 0; i < MOD_MAX; i++)
   284                  mod[i] = NULL;
   285  
   286          /*
   287           * in play case...
   288           *
   289           * src -> dst
   290           *
   291           * mem -> SSI
   292           * mem -> SRC -> SSI
   293           * mem -> SRC -> DVC -> SSI

I don't understand what this comment means.

   294           */
   295          mod[0] = NULL; /* for "mem" */

We memset everything to NULL in the loop above so this isn't needed.

   296          index = 1;
   297          for (i = 1; i < MOD_MAX; i++) {
   298                  if (!src) {
   299                          mod[i] = ssi;
   300                          break;
   301                  } else if (!dvc) {
   302                          mod[i] = src;
   303                          src = NULL;
   304                  } else {
   305                          mod[i] = dvc;
   306                          dvc = NULL;
   307                  }
   308  
   309                  if (mod[i] == this)
   310                          index = i;

In theory, index can be MOD_MAX - 1.

   311          }
   312  
   313          if (is_play) {
   314                  src_mod = mod[index - 1];
   315                  dst_mod = mod[index];
   316          } else {
   317                  src_mod = mod[index];
   318                  dst_mod = mod[index + 1];

So then it complains that mod[] has only MOD_MAX elements so we're one
space past the end of the array.  Probably the way this is called, there
is something to prevent it?

   319          }

regards,
dan carpenter

             reply	other threads:[~2014-06-10 18:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-10 18:02 Dan Carpenter [this message]
2014-06-11  0:59 ` ASoC: rsnd: care DMA slave channel name for DT Kuninori Morimoto

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=20140610180245.GA12361@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kuninori.morimoto.gx@renesas.com \
    /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 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.