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: 4206641 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C01BC9F32A for ; Mon, 19 May 2014 21:40:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 022D0202FE for ; Mon, 19 May 2014 21:40:11 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3713A202F0 for ; Mon, 19 May 2014 21:40:10 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WmVEw-0001jx-UK; Mon, 19 May 2014 21:36:58 +0000 Received: from mail-ee0-f47.google.com ([74.125.83.47]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WmVEu-0001ij-DE for linux-arm-kernel@lists.infradead.org; Mon, 19 May 2014 21:36:57 +0000 Received: by mail-ee0-f47.google.com with SMTP id c13so4007531eek.6 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=QbEgUG2ILaQhuxIDCeHaPNoyk305iBKEe61UixE/LN521wBc4Uvx/sXAMmITSVUN4v JxRu4zosjVDGfcH49zYCezgDaDZof0dRAepKlCc0oaPdOA1kb90vAhxEn5W9qHecgQHL O+NNrXSah9eCAcC06/q5YgfwrFK3gdI8nQF+Gh/UzoN3rz8brMZvCxUBIur2brArdyGR akFksPeEDkf2jcNVzKw1DqBFjJ9ZpPjSllmxgflrJVtSvUpWqV1TiCfHh5TT95XIuLJ6 0eS8mfj189Q6k4Do4k2k3kJJmELKQvfP2pLgEkVnrlHiGEWjb3x3H9K2nAnMO2qQDdoJ +9Ow== X-Gm-Message-State: ALoCoQkXZvUs1t3eFXixKZNs3EzvV5zrQ1ChqFPpEu/UzDh1ef+dPyQGF8hsKepjT5Qd7LWU7ESH 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 Subject: [PATCH] sound: soc: samsung: dma.c: Fix for possible null pointer dereference 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140519_143656_595631_CE57A9B8 X-CRM114-Status: GOOD ( 11.93 ) X-Spam-Score: -0.7 (/) Cc: alsa-devel@alsa-project.org, linux-samsung-soc@vger.kernel.org, Rickard Strandqvist , Sangbeom Kim , linux-kernel@vger.kernel.org, Liam Girdwood , Jaroslav Kysela , Takashi Iwai , Mark Brown , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.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()) {