From patchwork Wed Nov 21 09:06:56 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 13031 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 667B023FC9 for ; Wed, 21 Nov 2012 09:19:20 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 16281A193B5 for ; Wed, 21 Nov 2012 09:19:19 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so9540530iej.11 for ; Wed, 21 Nov 2012 01:19:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=cF8mcnv87X8Wr+cisUObmSInp8jsVg28wyQuVX6aYUk=; b=Oe4HRo/c5uUAAL9qu1F837+I7fh5OZvQLmygnT2PSHyJgmOBH9BAwrFc47hMZfJcfQ AlWwlsisOkLiecaVeWaF3b2BIK72qR0qEmbHBNpWYQO1LUaZq3UsVC6OSzMKjEZmMRGi p9jdeYWTY+YfXBew9P/ey70qxTrkdGOC91vJAWbFZ7l7SQamZRTNbgwA4YN9o8ERJx5N EUpt+WPxeb7TCSurnD+Qb9rXYNV+fOx5+PNvy3BqoyYgquEzPKKH0WfCHDqkaAyJL8b0 gL9zNuIwye8rS3aPFehxyRpstRA2LDI8nWCgmgklv4yUFT+/BE6W4W+FFrIp6peV5Dy/ geuA== Received: by 10.50.161.169 with SMTP id xt9mr12756544igb.62.1353489559485; Wed, 21 Nov 2012 01:19:19 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp433igt; Wed, 21 Nov 2012 01:19:19 -0800 (PST) Received: by 10.68.253.4 with SMTP id zw4mr51781982pbc.143.1353489229967; Wed, 21 Nov 2012 01:13:49 -0800 (PST) Received: from mail-pa0-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by mx.google.com with ESMTPS id uq10si21841447pbc.287.2012.11.21.01.13.19 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Nov 2012 01:13:49 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.53 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) client-ip=209.85.220.53; Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.53 is neither permitted nor denied by best guess record for domain of sachin.kamat@linaro.org) smtp.mail=sachin.kamat@linaro.org Received: by mail-pa0-f53.google.com with SMTP id hz1so1387246pad.12 for ; Wed, 21 Nov 2012 01:13:19 -0800 (PST) Received: by 10.68.189.8 with SMTP id ge8mr58438138pbc.24.1353489199881; Wed, 21 Nov 2012 01:13:19 -0800 (PST) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id mn5sm9621802pbc.12.2012.11.21.01.13.16 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 21 Nov 2012 01:13:19 -0800 (PST) From: Sachin Kamat To: alsa-devel@alsa-project.org Cc: perex@perex.cz, tiwai@suse.de, broonie@opensource.wolfsonmicro.com, lrg@ti.com, sachin.kamat@linaro.org, patches@linaro.org, Sangbeom Kim Subject: [PATCH 3/6] ASoC: Samsung-dma: Fix potential NULL pointer dereference Date: Wed, 21 Nov 2012 14:36:56 +0530 Message-Id: <1353488819-13902-3-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1353488819-13902-1-git-send-email-sachin.kamat@linaro.org> References: <1353488819-13902-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQmEA8naiLKt+X/tC74PSgywC18cpNpd4X0NKImuQehbSKMqt+AmaGZoCQrX1j60OPTSmClp 'substream' was dereferenced before the NULL check. Moved the check earlier to prevent NULL pointer dereference. Cc: Sangbeom Kim Cc: Mark Brown Signed-off-by: Sachin Kamat --- Build tested and based on linux-next 20121115. --- sound/soc/samsung/dma.c | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index b70964e..e59a4f4 100644 --- a/sound/soc/samsung/dma.c +++ b/sound/soc/samsung/dma.c @@ -114,17 +114,23 @@ 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; pr_debug("Entered %s\n", __func__); + if (substream) { + prtd = substream->runtime->private_data; + } else { + pr_err("%s: Null data received\n", __func__); + return; + } + if (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()) {