[alsa-devel] [bug report] ASoC: hdac_hdmi: Add support for multiple ports to a PCM

Dan Carpenter dan.carpenter at oracle.com
Wed Feb 22 20:07:58 CET 2017


Hello Jeeja KP,

The patch e0e5d3e5a53b: "ASoC: hdac_hdmi: Add support for multiple
ports to a PCM" from Feb 7, 2017, leads to the following static
checker warning:

	sound/soc/codecs/hdac_hdmi.c:2011 hdac_hdmi_dev_remove()
	error: potential NULL dereference 'port'.

sound/soc/codecs/hdac_hdmi.c
  1995  static int hdac_hdmi_dev_remove(struct hdac_ext_device *edev)
  1996  {
  1997          struct hdac_hdmi_priv *hdmi = edev->private_data;
  1998          struct hdac_hdmi_pin *pin, *pin_next;
  1999          struct hdac_hdmi_cvt *cvt, *cvt_next;
  2000          struct hdac_hdmi_pcm *pcm, *pcm_next;
  2001          struct hdac_hdmi_port *port;
  2002          int i;
  2003  
  2004          snd_soc_unregister_codec(&edev->hdac.dev);
  2005  
  2006          list_for_each_entry_safe(pcm, pcm_next, &hdmi->pcm_list, head) {
  2007                  pcm->cvt = NULL;
  2008                  if (list_empty(&pcm->port_list))
  2009                          continue;
  2010  
  2011                  list_for_each_entry(port, &pcm->port_list, head)
  2012                          port = NULL;

It's not clear to me what this loop is supposed to do.  To me it looks
like it will Oops every single time without fail.

  2013  
  2014                  list_del(&pcm->head);
  2015                  kfree(pcm);
  2016          }
  2017  
  2018          list_for_each_entry_safe(cvt, cvt_next, &hdmi->cvt_list, head) {
  2019                  list_del(&cvt->head);
  2020                  kfree(cvt->name);
  2021                  kfree(cvt);
  2022          }
  2023  
  2024          list_for_each_entry_safe(pin, pin_next, &hdmi->pin_list, head) {
  2025                  for (i = 0; i < pin->num_ports; i++)
  2026                          pin->ports[i].pin = NULL;
  2027                  kfree(pin->ports);
  2028                  list_del(&pin->head);
  2029                  kfree(pin);
  2030          }
  2031  
  2032          return 0;
  2033  }

regards,
dan carpenter


More information about the Alsa-devel mailing list