From: Michaƫl Cadilhac Date: Mon, 22 Feb 2010 08:59:26 +0000 (+0100) Subject: usb_stream: Check for NULL-ness before dereferencing X-Git-Tag: v1.0.23~2 X-Git-Url: https://git.alsa-project.org/?a=commitdiff_plain;h=e3b3c401bb9f6ff4d428600350a53c952ad1747e;p=alsa-plugins.git usb_stream: Check for NULL-ness before dereferencing * usb_stream/pcm_usb_stream.c (snd_pcm_us_stop): Prevent dereferencing when structure is not initialized. Signed-off-by: Takashi Iwai --- diff --git a/usb_stream/pcm_usb_stream.c b/usb_stream/pcm_usb_stream.c index 4097693..cd761fb 100644 --- a/usb_stream/pcm_usb_stream.c +++ b/usb_stream/pcm_usb_stream.c @@ -1,7 +1,7 @@ /* * PCM - USB_STREAM plugin * - * Copyright (c) 2008 by Karsten Wiese + * Copyright (c) 2008, 2010 by Karsten Wiese * * This library is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as @@ -256,8 +256,11 @@ static int snd_pcm_us_start(snd_pcm_ioplug_t *io) static int snd_pcm_us_stop(snd_pcm_ioplug_t *io) { snd_pcm_us_t *us = io->private_data; - VDBG("%u", us->uus->s->periods_done); + if (!us->uus->s) + return 0; + + VDBG("%u", us->uus->s->periods_done); if (io->stream == SND_PCM_STREAM_PLAYBACK) memset(us->uus->write_area, 0, us->uus->s->write_size);