From patchwork Thu May 15 21:57:56 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rickard Strandqvist X-Patchwork-Id: 4186301 Return-Path: X-Original-To: patchwork-linux-arm@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 A39F1BFF02 for ; Thu, 15 May 2014 22:00:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AE86620395 for ; Thu, 15 May 2014 22:00:27 +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 9AAF720121 for ; Thu, 15 May 2014 22:00:26 +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 1Wl3el-0000Hf-F5; Thu, 15 May 2014 21:57:39 +0000 Received: from mail-ee0-f52.google.com ([74.125.83.52]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wl3eh-00009j-Dv for linux-arm-kernel@lists.infradead.org; Thu, 15 May 2014 21:57:36 +0000 Received: by mail-ee0-f52.google.com with SMTP id e53so1003504eek.25 for ; Thu, 15 May 2014 14:57:12 -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:mime-version :content-type:content-transfer-encoding; bh=T9EG5Ra/BZgKz3AIs4ZvQlb2noaqD0+ajXZVFCxJp/I=; b=PcE8djtaebvqE09nGThjm7fx6ME9AdRaI/5wrSGN9E6jYBgbVlpZ6hWda63kDpEKEI fTS8bwqMVryDp2N0VZCrKYDW2iwgYBUDMW4QarrIegjNE4qvgPhFxRaMIEjBy+WwE7P7 MryC3//SzbhbkQIrkpaXm/8eViQeuynQFI/s+QsZtLdRZXrt1PXJRIcDngw/UkldPwiV /D4O8xZEa5s7w3KnCSe1h68BRCZa3FPz9wDbglE5i66RlfslxmMvty8tFQ4gWXyRneZI 7u/+rmURcXSdIEM3hQXoql/yvGcfmFCY6MoIy9nltdxXdr9pvTcYBo8hh56h/Z1YufdK V5sw== X-Gm-Message-State: ALoCoQln7/1QkYlHRTT4zW7wqUe7n63r+y8ffo3bXi6K8ruS8CEm6ZednwSXZziDt+BUje9NZUmn X-Received: by 10.14.99.68 with SMTP id w44mr6239417eef.82.1400191032098; Thu, 15 May 2014 14:57:12 -0700 (PDT) Received: from localhost.localdomain (h-245-62.a218.priv.bahnhof.se. [85.24.245.62]) by mx.google.com with ESMTPSA id f3sm15405119eep.40.2014.05.15.14.57.10 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 May 2014 14:57:11 -0700 (PDT) From: Rickard Strandqvist To: Ben Dooks , Kukjin Kim Subject: =?UTF-8?q?=5BPATCH=5D=20Fix=20for=20possible=20null=20pointer=20dereference=20in=20dma=2Ec?= Date: Thu, 15 May 2014 23:57:56 +0200 Message-Id: <1400191076-28279-1-git-send-email-rickard_strandqvist@spectrumdigital.se> X-Mailer: git-send-email 1.7.10.4 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140515_145735_665445_940419E2 X-CRM114-Status: GOOD ( 10.06 ) 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: , 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 fil ändrad, 6 tillägg(+), 4 borttagningar(-) diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c index dc09b71..b1f6757 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()) {