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: 4206591 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 0D01EBEEAB for ; Mon, 19 May 2014 21:36:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 382E4202FE for ; Mon, 19 May 2014 21:36:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 367A2202B4 for ; Mon, 19 May 2014 21:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751074AbaESVgf (ORCPT ); Mon, 19 May 2014 17:36:35 -0400 Received: from mail-ee0-f52.google.com ([74.125.83.52]:35077 "EHLO mail-ee0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750838AbaESVge (ORCPT ); Mon, 19 May 2014 17:36:34 -0400 Received: by mail-ee0-f52.google.com with SMTP id e53so4016983eek.39 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=jtvXEyLysiybhiX1lsUlOuD7pNiviYtfVTFtlrhBg18FWIVjOx/p4DQLoGPEnWG89w Y+8co9Z0JIA110cA2JsBniSjqmEtVrTA7hEeJkaWdMzuSsqc32ZuzlZzjVUvn/UmAuwz 5Dlph3errL4kataHSvmaODF0biJJS6c/RhRrg/sMJanWDcqvLY/dwifG7FKds68QcV4L 73glVadBE3nheBKLioJVA7hr7fdX0UfuVZTr4obcOByLpLeVwLtiUwEAEDVsAeDRauMJ 1XuRrZrMUwLNvg1OOI+l2dLhY3mNFCjuy/EDcUbaIscsZQ/gLdxZoqbb3Y+mlAiytr78 yY7g== X-Gm-Message-State: ALoCoQmhVYz31tphNjPqJgYJ/3yKIdGTPMDxjDC5P1mIXC7Rny4BCma30Z9oKPGeaZy+m45JlppV 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 Cc: Rickard Strandqvist , Sangbeom Kim , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org 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 Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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()) {