From patchwork Mon May 19 21:37:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 4206611 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9D52FBEEAB for ; Mon, 19 May 2014 21:36:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B0AC920172 for ; Mon, 19 May 2014 21:36:57 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id C39172013D for ; Mon, 19 May 2014 21:36:55 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 77E182610C7; Mon, 19 May 2014 23:36:54 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 6D353260851; Mon, 19 May 2014 23:36: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 9E651260851; Mon, 19 May 2014 23:36:41 +0200 (CEST) Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) by alsa0.perex.cz (Postfix) with ESMTP id 9916D260815 for ; Mon, 19 May 2014 23:36:33 +0200 (CEST) Received: by mail-ee0-f53.google.com with SMTP id c13so3987928eek.26 for ; Mon, 19 May 2014 14:36:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ut+6gPr8QmHx0OOqUbNXpQ0HOByyuZbbYK5H3WV7gjc=; b=gfzl+icXc08d/nPj2oIMKmE9wFTUN6zLHKwMa5GjYFtmRInegRdvRCSmww+Se9Eab+ jmTOAvx3d0yS+x8izY7gZTWxggqBxgMaMcwh3YzynFEv1TTZDEQ1FhSjUTH0SVwzQ7A9 msE01695V9+jkpUvu6fxQIFPzZ3fJJ57llVjaKICFQvrmQkpZNsAnNK/tptIBuOY6G/0 ujaKeiBeUqhuInmNrq8Ul8dKnpd1BCXlW0tAAXbyP13y4WJHXEI0EIDtvuRdeeJhKBwi uNALw48eL/yQnqI3g1yI3R+2u2CV2kex6PCswA5vABOTT8vA2JgrzowUwtoZMxSxdmT9 S0jA== X-Gm-Message-State: ALoCoQmPCyFsX0JbMTUCr05BTdVN0K32eVu2TfUFOKVD2bIk+gq25O8U0PLMLI9S3zguqHSkTRX3 X-Received: by 10.14.37.3 with SMTP id x3mr7612173eea.96.1400535393336; Mon, 19 May 2014 14:36:33 -0700 (PDT) Received: from localhost.localdomain (h-245-62.a218.priv.bahnhof.se. [85.24.245.62]) by mx.google.com with ESMTPSA id ci54sm44623708eeb.19.2014.05.19.14.36.31 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 May 2014 14:36:32 -0700 (PDT) From: Rickard Strandqvist To: Ben Dooks , Kukjin Kim Date: Mon, 19 May 2014 23:37:23 +0200 Message-Id: <1400535443-5886-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 Cc: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, Rickard Strandqvist , Sangbeom Kim , linux-kernel@vger.kernel.org, Liam Girdwood , Takashi Iwai , Mark Brown , linux-arm-kernel@lists.infradead.org Subject: [alsa-devel] [PATCH] sound: soc: samsung: dma.c: Fix for possible null pointer dereference 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP There is otherwise a risk of a possible null pointer dereference. Was largely found by using a static code analysis program called cppcheck. Signed-off-by: Rickard Strandqvist --- sound/soc/samsung/dma.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index dc09b71..1d9bcaa 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c @@ -115,17 +115,19 @@ static void dma_enqueue(struct snd_pcm_substream *substream) static void audio_buffdone(void *data) { struct snd_pcm_substream *substream = data; - struct runtime_data *prtd = substream->runtime->private_data; + struct runtime_data *prtd = NULL; pr_debug("Entered %s\n", __func__); - if (prtd->state & ST_RUNNING) { + if (substream) + prtd = substream->runtime->private_data; + + if (prtd && prtd->state & ST_RUNNING) { prtd->dma_pos += prtd->dma_period; if (prtd->dma_pos >= prtd->dma_end) prtd->dma_pos = prtd->dma_start; - if (substream) - snd_pcm_period_elapsed(substream); + snd_pcm_period_elapsed(substream); spin_lock(&prtd->lock); if (!samsung_dma_has_circular()) {