Skip to content

Commit

Permalink
media: cx23885: Fix snd_card_free call on null card pointer
Browse files Browse the repository at this point in the history
[ Upstream commit 7266dda ]

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: 9e44d63 ("[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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Colin Ian King authored and gregkh committed Nov 18, 2021
1 parent 388cebf commit c34bfe4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/media/pci/cx23885/cx23885-alsa.c
Expand Up @@ -550,7 +550,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)
SNDRV_DEFAULT_IDX1, SNDRV_DEFAULT_STR1,
THIS_MODULE, sizeof(struct cx23885_audio_dev), &card);
if (err < 0)
goto error;
goto error_msg;

chip = (struct cx23885_audio_dev *) card->private_data;
chip->dev = dev;
Expand All @@ -576,6 +576,7 @@ struct cx23885_audio_dev *cx23885_audio_register(struct cx23885_dev *dev)

error:
snd_card_free(card);
error_msg:
pr_err("%s(): Failed to register analog audio adapter\n",
__func__);

Expand Down

0 comments on commit c34bfe4

Please sign in to comment.