[alsa-devel] ALSA: tons of false positives because of snd_ctl_find_id()
Takashi Iwai
tiwai at suse.de
Mon Feb 12 14:20:09 CET 2018
On Fri, 02 Feb 2018 10:57:28 +0100,
Dan Carpenter wrote:
>
> On Fri, Feb 02, 2018 at 06:07:14PM +0900, Takashi Sakamoto wrote:
> >
> > In a design of ALSA control core, each element can be pointed according
> > to data of 'struct snd_ctl_elem_id'. There're two independent ways to
> > indicate arbitrary element:
> > 1. by 'numerical ID' (.numid)
> > 2. by a combination of 'interface' (.iface), 'device' (.device),
> > 'sub device' (.subdevice), 'name' (.name) and 'index' (.index).
> >
> > For our information, in ALSA control core, some elements with the same
> > attributes are managed by data of 'struct snd_kcontrol'. I call it as
> > 'element set'. The value of '.index' represents offset from the first
> > element in the element set for a target element.
> >
> > I don't get your concern clearly. But it's my pleasure that the above
> > information will help you if you missed the two ways.
> >
>
> Right. Thanks. I understood all that...
>
> I've actually figured out a hack that will probably work fine to fix my
> issue. Smatch provides a way to hand edit the cross function DB:
> http://repo.or.cz/smatch.git/blob/HEAD:/smatch_data/db/fixup_kernel.sh
> I can probably solve this by adding a few lines of code to that file.
> I'm testing it now.
>
> What I was trying to say was even though we don't need to check .index
> since we're not using it, it would simplify static analysis if we would
> would set it to zero. It shouldn't hurt anything since we're not going
> to use it.
Actually the value index is copied from the kctl->id before calling
the get and put callbacks. In snd_ctl_elem_read() and
snd_ctl_elem_write(), both call snd_ctl_build_ioff() just before
kctl->get() and kctl->put() calls. This overwrites both index and
numid fields with the correction of the offset.
Takashi
More information about the Alsa-devel
mailing list