aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2013-05-29 09:44:22 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-08 19:24:56 -0400
commit609c4c12af79b1ba5fd2d31727a95dd3a319c0ae (patch)
tree31d41ee5768f3d3ef56ad0c4d8aa75fb12a41a22 /drivers/media
parentdfd50fc9030a62521838eecbe488e1962edcba80 (diff)
[media] cx88: fix NULL pointer dereference
This fixes a NULL pointer deference when loading the cx88_dvb module for a Hauppauge HVR4000. The bugzilla bug report is here: https://bugzilla.kernel.org/show_bug.cgi?id=56271 The cause is that the wm8775 is optional, so even though the board info says there is one, it doesn't have to be there. Checking whether the module was actually loaded is much safer. Note that this driver is quite buggy when it comes to unloading and reloading modules. Unloading cx8800 and reloading it again will still cause a crash, most likely because either the i2c bus isn't unloaded at the right time and/or the v4l2_device_unregister isn't called at the right time. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reported-by: Sebastian Frei <sebastian@familie-frei.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/pci/cx88/cx88-alsa.c7
-rw-r--r--drivers/media/pci/cx88/cx88-video.c8
2 files changed, 6 insertions, 9 deletions
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c
index 27d62623274b..aba5b1c649e6 100644
--- a/drivers/media/pci/cx88/cx88-alsa.c
+++ b/drivers/media/pci/cx88/cx88-alsa.c
@@ -615,7 +615,7 @@ static int snd_cx88_volume_put(struct snd_kcontrol *kcontrol,
615 int changed = 0; 615 int changed = 0;
616 u32 old; 616 u32 old;
617 617
618 if (core->board.audio_chip == V4L2_IDENT_WM8775) 618 if (core->sd_wm8775)
619 snd_cx88_wm8775_volume_put(kcontrol, value); 619 snd_cx88_wm8775_volume_put(kcontrol, value);
620 620
621 left = value->value.integer.value[0] & 0x3f; 621 left = value->value.integer.value[0] & 0x3f;
@@ -682,8 +682,7 @@ static int snd_cx88_switch_put(struct snd_kcontrol *kcontrol,
682 vol ^= bit; 682 vol ^= bit;
683 cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol); 683 cx_swrite(SHADOW_AUD_VOL_CTL, AUD_VOL_CTL, vol);
684 /* Pass mute onto any WM8775 */ 684 /* Pass mute onto any WM8775 */
685 if ((core->board.audio_chip == V4L2_IDENT_WM8775) && 685 if (core->sd_wm8775 && ((1<<6) == bit))
686 ((1<<6) == bit))
687 wm8775_s_ctrl(core, V4L2_CID_AUDIO_MUTE, 0 != (vol & bit)); 686 wm8775_s_ctrl(core, V4L2_CID_AUDIO_MUTE, 0 != (vol & bit));
688 ret = 1; 687 ret = 1;
689 } 688 }
@@ -903,7 +902,7 @@ static int cx88_audio_initdev(struct pci_dev *pci,
903 goto error; 902 goto error;
904 903
905 /* If there's a wm8775 then add a Line-In ALC switch */ 904 /* If there's a wm8775 then add a Line-In ALC switch */
906 if (core->board.audio_chip == V4L2_IDENT_WM8775) 905 if (core->sd_wm8775)
907 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip)); 906 snd_ctl_add(card, snd_ctl_new1(&snd_cx88_alc_switch, chip));
908 907
909 strcpy (card->driver, "CX88x"); 908 strcpy (card->driver, "CX88x");
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index 1b00615fd395..c7a9be1065c0 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -385,8 +385,7 @@ int cx88_video_mux(struct cx88_core *core, unsigned int input)
385 /* The wm8775 module has the "2" route hardwired into 385 /* The wm8775 module has the "2" route hardwired into
386 the initialization. Some boards may use different 386 the initialization. Some boards may use different
387 routes for different inputs. HVR-1300 surely does */ 387 routes for different inputs. HVR-1300 surely does */
388 if (core->board.audio_chip && 388 if (core->sd_wm8775) {
389 core->board.audio_chip == V4L2_IDENT_WM8775) {
390 call_all(core, audio, s_routing, 389 call_all(core, audio, s_routing,
391 INPUT(input).audioroute, 0, 0); 390 INPUT(input).audioroute, 0, 0);
392 } 391 }
@@ -771,8 +770,7 @@ static int video_open(struct file *file)
771 cx_write(MO_GP1_IO, core->board.radio.gpio1); 770 cx_write(MO_GP1_IO, core->board.radio.gpio1);
772 cx_write(MO_GP2_IO, core->board.radio.gpio2); 771 cx_write(MO_GP2_IO, core->board.radio.gpio2);
773 if (core->board.radio.audioroute) { 772 if (core->board.radio.audioroute) {
774 if(core->board.audio_chip && 773 if (core->sd_wm8775) {
775 core->board.audio_chip == V4L2_IDENT_WM8775) {
776 call_all(core, audio, s_routing, 774 call_all(core, audio, s_routing,
777 core->board.radio.audioroute, 0, 0); 775 core->board.radio.audioroute, 0, 0);
778 } 776 }
@@ -959,7 +957,7 @@ static int cx8800_s_aud_ctrl(struct v4l2_ctrl *ctrl)
959 u32 value,mask; 957 u32 value,mask;
960 958
961 /* Pass changes onto any WM8775 */ 959 /* Pass changes onto any WM8775 */
962 if (core->board.audio_chip == V4L2_IDENT_WM8775) { 960 if (core->sd_wm8775) {
963 switch (ctrl->id) { 961 switch (ctrl->id) {
964 case V4L2_CID_AUDIO_MUTE: 962 case V4L2_CID_AUDIO_MUTE:
965 wm8775_s_ctrl(core, ctrl->id, ctrl->val); 963 wm8775_s_ctrl(core, ctrl->id, ctrl->val);