diff options
author | Subhransu S. Prusty <subhransu.s.prusty@intel.com> | 2017-11-07 05:46:25 -0500 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2017-11-08 13:58:24 -0500 |
commit | eb50fa1739a63cc4b202b40a62d71055a2d7b80c (patch) | |
tree | cbae0061a34ec9cd3f28d6a8ca4b4470e8d06c3a | |
parent | 70e97a2d9c5266487dfec4cade28f8e587927f04 (diff) |
ASoC: hdac_hdmi: Fix possible NULL pointer dereference
Pointers hdac_hdmi_pcm and hda_device_id can be NULL, so add check for
valid pointer to avoid NULL pointer dereference.
Signed-off-by: Subhransu S. Prusty <subhransu.s.prusty@intel.com>
Signed-off-by: Guneshwor Singh <guneshwor.o.singh@intel.com>
Acked-By: Vinod Koul <vinod.koul@intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r-- | sound/soc/codecs/hdac_hdmi.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/sound/soc/codecs/hdac_hdmi.c b/sound/soc/codecs/hdac_hdmi.c index 6f3ff15c0962..0c0aa6182502 100644 --- a/sound/soc/codecs/hdac_hdmi.c +++ b/sound/soc/codecs/hdac_hdmi.c | |||
@@ -1895,6 +1895,9 @@ static void hdac_hdmi_set_chmap(struct hdac_device *hdac, int pcm_idx, | |||
1895 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); | 1895 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); |
1896 | struct hdac_hdmi_port *port; | 1896 | struct hdac_hdmi_port *port; |
1897 | 1897 | ||
1898 | if (!pcm) | ||
1899 | return; | ||
1900 | |||
1898 | if (list_empty(&pcm->port_list)) | 1901 | if (list_empty(&pcm->port_list)) |
1899 | return; | 1902 | return; |
1900 | 1903 | ||
@@ -1913,6 +1916,9 @@ static bool is_hdac_hdmi_pcm_attached(struct hdac_device *hdac, int pcm_idx) | |||
1913 | struct hdac_hdmi_priv *hdmi = edev->private_data; | 1916 | struct hdac_hdmi_priv *hdmi = edev->private_data; |
1914 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); | 1917 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); |
1915 | 1918 | ||
1919 | if (!pcm) | ||
1920 | return false; | ||
1921 | |||
1916 | if (list_empty(&pcm->port_list)) | 1922 | if (list_empty(&pcm->port_list)) |
1917 | return false; | 1923 | return false; |
1918 | 1924 | ||
@@ -1926,6 +1932,9 @@ static int hdac_hdmi_get_spk_alloc(struct hdac_device *hdac, int pcm_idx) | |||
1926 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); | 1932 | struct hdac_hdmi_pcm *pcm = get_hdmi_pcm_from_id(hdmi, pcm_idx); |
1927 | struct hdac_hdmi_port *port; | 1933 | struct hdac_hdmi_port *port; |
1928 | 1934 | ||
1935 | if (!pcm) | ||
1936 | return 0; | ||
1937 | |||
1929 | if (list_empty(&pcm->port_list)) | 1938 | if (list_empty(&pcm->port_list)) |
1930 | return 0; | 1939 | return 0; |
1931 | 1940 | ||
@@ -1979,6 +1988,9 @@ static int hdac_hdmi_dev_probe(struct hdac_ext_device *edev) | |||
1979 | hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; | 1988 | hdmi_priv->chmap.ops.is_pcm_attached = is_hdac_hdmi_pcm_attached; |
1980 | hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; | 1989 | hdmi_priv->chmap.ops.get_spk_alloc = hdac_hdmi_get_spk_alloc; |
1981 | 1990 | ||
1991 | if (!hdac_id) | ||
1992 | return -ENODEV; | ||
1993 | |||
1982 | if (hdac_id->driver_data) | 1994 | if (hdac_id->driver_data) |
1983 | hdmi_priv->drv_data = | 1995 | hdmi_priv->drv_data = |
1984 | (struct hdac_hdmi_drv_data *)hdac_id->driver_data; | 1996 | (struct hdac_hdmi_drv_data *)hdac_id->driver_data; |