[alsa-devel] [bug report] ASoC: rsnd: call missing snd_ctl_remove()

Dan Carpenter dan.carpenter at oracle.com
Thu Dec 15 10:44:29 CET 2016


Hello Kuninori Morimoto,

The patch d1f83d6ef43b: "ASoC: rsnd: call missing snd_ctl_remove()"
from Feb 2, 2015, leads to the following static checker warning:

	sound/soc/sh/rcar/core.c:1034 __rsnd_kctrl_new()
	error: double free of 'kctrl'

sound/soc/sh/rcar/core.c
  1026          int ret;
  1027  
  1028          kctrl = snd_ctl_new1(&knew, mod);
  1029          if (!kctrl)
  1030                  return -ENOMEM;
  1031  
  1032          ret = snd_ctl_add(card, kctrl);
  1033          if (ret < 0) {
  1034                  snd_ctl_free_one(kctrl);

The snd_ctl_add() function frees kctrl on error.  It's a confusing
layering violation IMHO but there are a lot of callers so I'm too lazy
to clean this up myself...

  1035                  return ret;
  1036          }
  1037  

regards,
dan carpenter


More information about the Alsa-devel mailing list