From patchwork Fri Jun 17 03:02:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oder Chiou X-Patchwork-Id: 9182395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 810546075D for ; Fri, 17 Jun 2016 03:03:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 741EF28379 for ; Fri, 17 Jun 2016 03:03:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6728C2839F; Fri, 17 Jun 2016 03:03:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CCD428379 for ; Fri, 17 Jun 2016 03:03:19 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 1FE3826590B; Fri, 17 Jun 2016 05:03:16 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id DBCD6265831; Fri, 17 Jun 2016 05:02:43 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 3367A2657F4; Fri, 17 Jun 2016 05:02:42 +0200 (CEST) Received: from rtits2.realtek.com.tw (rtits2.realtek.com [60.250.210.242]) by alsa0.perex.cz (Postfix) with ESMTP id 9E26C2657B1 for ; Fri, 17 Jun 2016 05:02:34 +0200 (CEST) Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.56 with qID u5H32Se4003489, This message is accepted by code: ctloc85258 Received: from mail.realtek.com (rtitcas12.realtek.com.tw[172.21.6.16]) by rtits2.realtek.com.tw (8.14.9/2.42/5.68) with ESMTP id u5H32Se4003489 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NOT); Fri, 17 Jun 2016 11:02:29 +0800 Received: from RTITCASV01.realtek.com.tw (172.21.6.18) by RTITCAS12.realtek.com.tw (172.21.6.16) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 17 Jun 2016 11:02:29 +0800 Received: from sw-server.rtdomain (172.21.85.85) by RTITCASV01.realtek.com.tw (172.21.6.18) with Microsoft SMTP Server id 14.3.294.0; Fri, 17 Jun 2016 11:02:28 +0800 From: Oder Chiou To: , Date: Fri, 17 Jun 2016 11:02:23 +0800 Message-ID: <1466132544-22916-1-git-send-email-oder_chiou@realtek.com> X-Mailer: git-send-email 1.8.1.1.439.g50a6b54 MIME-Version: 1.0 X-Originating-IP: [172.21.85.85] Cc: Oder Chiou , jack.yu@realtek.com, alsa-devel@alsa-project.org, shumingf@realtek.com, bardliao@realtek.com, flove@realtek.com Subject: [alsa-devel] [PATCH 1/2] ASoC: rt5514: Fix the issue that the variable dereferenced before checking X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The patch fixes the issue that variable dereferenced before checking 'rt5514_dsp->substream'. Move the assignment to after the variable checking of 'rt5514_dsp->substream'. Signed-off-by: Oder Chiou --- sound/soc/codecs/rt5514-spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/rt5514-spi.c b/sound/soc/codecs/rt5514-spi.c index 8a9382e..743f509 100644 --- a/sound/soc/codecs/rt5514-spi.c +++ b/sound/soc/codecs/rt5514-spi.c @@ -80,7 +80,7 @@ static void rt5514_spi_copy_work(struct work_struct *work) { struct rt5514_dsp *rt5514_dsp = container_of(work, struct rt5514_dsp, copy_work.work); - struct snd_pcm_runtime *runtime = rt5514_dsp->substream->runtime; + struct snd_pcm_runtime *runtime; size_t period_bytes, truncated_bytes = 0; mutex_lock(&rt5514_dsp->dma_lock); @@ -89,6 +89,7 @@ static void rt5514_spi_copy_work(struct work_struct *work) goto done; } + runtime = rt5514_dsp->substream->runtime; period_bytes = snd_pcm_lib_period_bytes(rt5514_dsp->substream); if (rt5514_dsp->buf_size - rt5514_dsp->dsp_offset < period_bytes)