diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-08-26 01:22:49 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-08-26 01:43:47 -0400 |
commit | a92d5ee8666afcb4abc7686d7b760f0fb7a0c14c (patch) | |
tree | 416230268de6d2d4017974c3f8f5656ded436f81 /sound/hda | |
parent | 654e2751c9f00491c4622893de59a21784e39ccf (diff) |
ALSA: hda - Fix widget sysfs tree corruption after refresh
When snd_hdac_refresh_widget_sysfs() is called before the first
hda_widget_sysfs_init(), the next call overrides and eventually
fails. This results in unexpected Oops, something like:
BUG: unable to handle kernel NULL pointer dereference at 00000000000000c8
IP: [<ffffffff8180e2a3>] hdmi_chmap_ctl_info+0x23/0x40
The fix is to add a check of the existing sysfs tree. Also, for more
safety, this patch adds the checks of device_is_registered() in
snd-hdac_refresh_wdiget_sysfs(), too.
Fixes: fa4f18b4f402 ('ALSA: hda - Refresh widgets sysfs at probing Haswell+ HDMI codecs')
Bugizlla: https://bugzilla.kernel.org/show_bug.cgi?id=103431
Reported-by: Andreas Reis <andreas.reis@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/hda')
-rw-r--r-- | sound/hda/hdac_device.c | 14 | ||||
-rw-r--r-- | sound/hda/hdac_sysfs.c | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/sound/hda/hdac_device.c b/sound/hda/hdac_device.c index aa6d6cec2380..db96042a497f 100644 --- a/sound/hda/hdac_device.c +++ b/sound/hda/hdac_device.c | |||
@@ -384,18 +384,20 @@ int snd_hdac_refresh_widget_sysfs(struct hdac_device *codec) | |||
384 | { | 384 | { |
385 | int ret; | 385 | int ret; |
386 | 386 | ||
387 | hda_widget_sysfs_exit(codec); | 387 | if (device_is_registered(&codec->dev)) |
388 | hda_widget_sysfs_exit(codec); | ||
388 | ret = snd_hdac_refresh_widgets(codec); | 389 | ret = snd_hdac_refresh_widgets(codec); |
389 | if (ret) { | 390 | if (ret) { |
390 | dev_err(&codec->dev, "failed to refresh widget: %d\n", ret); | 391 | dev_err(&codec->dev, "failed to refresh widget: %d\n", ret); |
391 | return ret; | 392 | return ret; |
392 | } | 393 | } |
393 | ret = hda_widget_sysfs_init(codec); | 394 | if (device_is_registered(&codec->dev)) { |
394 | if (ret) { | 395 | ret = hda_widget_sysfs_init(codec); |
395 | dev_err(&codec->dev, "failed to init sysfs: %d\n", ret); | 396 | if (ret) { |
396 | return ret; | 397 | dev_err(&codec->dev, "failed to init sysfs: %d\n", ret); |
398 | return ret; | ||
399 | } | ||
397 | } | 400 | } |
398 | |||
399 | return ret; | 401 | return ret; |
400 | } | 402 | } |
401 | EXPORT_SYMBOL_GPL(snd_hdac_refresh_widget_sysfs); | 403 | EXPORT_SYMBOL_GPL(snd_hdac_refresh_widget_sysfs); |
diff --git a/sound/hda/hdac_sysfs.c b/sound/hda/hdac_sysfs.c index 089b35f6f108..c71142dea98a 100644 --- a/sound/hda/hdac_sysfs.c +++ b/sound/hda/hdac_sysfs.c | |||
@@ -390,6 +390,9 @@ int hda_widget_sysfs_init(struct hdac_device *codec) | |||
390 | { | 390 | { |
391 | int err; | 391 | int err; |
392 | 392 | ||
393 | if (codec->widgets) | ||
394 | return 0; /* already created */ | ||
395 | |||
393 | err = widget_tree_create(codec); | 396 | err = widget_tree_create(codec); |
394 | if (err < 0) { | 397 | if (err < 0) { |
395 | widget_tree_free(codec); | 398 | widget_tree_free(codec); |