Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: cx23885: Fix snd_card_free call on null card pointer

Currently a call to snd_card_new that fails will set card with a NULL
pointer, this causes a null pointer dereference on the error cleanup
path when card it passed to snd_card_free. Fix this by adding a new
error exit path that does not call snd_card_free and exiting via this
new path.

Addresses-Coverity: ("Explicit null dereference")

Fixes: 9e44d63246a9 ("[media] cx23885: Add ALSA support")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

authored by

Colin Ian King and committed by
Mauro Carvalho Chehab
7266dda2 42bb98e4

+2 -1
+2 -1
drivers/media/pci/cx23885/cx23885-alsa.c
··· 550 550 SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1, 551 551 THIS_MODULE, sizeof(struct cx23885_audio_dev), &card); 552 552 if (err < 0) 553 - goto error; 553 + goto error_msg; 554 554 555 555 chip = (struct cx23885_audio_dev *) card->private_data; 556 556 chip->dev = dev; ··· 576 576 577 577 error: 578 578 snd_card_free(card); 579 + error_msg: 579 580 pr_err("%s(): Failed to register analog audio adapter\n", 580 581 __func__); 581 582