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: 4187681 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 186E5BFF02 for ; Fri, 16 May 2014 05:53:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5776F2026F for ; Fri, 16 May 2014 05:53:03 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id CAAF020179 for ; Fri, 16 May 2014 05:53:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id B38BD265299; Fri, 16 May 2014 07:53:00 +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 43E0026171D; Fri, 16 May 2014 07:50:56 +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 76B20264EBF; Thu, 15 May 2014 23:57:20 +0200 (CEST) Received: from mail-ee0-f48.google.com (mail-ee0-f48.google.com [74.125.83.48]) by alsa0.perex.cz (Postfix) with ESMTP id 7886B2625FE for ; Thu, 15 May 2014 23:57:12 +0200 (CEST) Received: by mail-ee0-f48.google.com with SMTP id e49so1008959eek.21 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=MzzVzpJl1SuitIZq3mXR8kTfdz6eWnmWDqsIrreELJm+z9C01YUKGQ7Hod83AwXla/ yAJNOptMc9l6wR5C/BgG4LiD6PGhHXVZjhKJ7Qi2j5EK4GNoEIFBOQm9+szehMbosDbM sqWVNUc3ZKZy4J4/fe3kIH4BkGatoUzkKtwecZqiW97V8nl6W80lF+pdxVYWfUd6jx1r MJxS78vN6HPBqZBdy2IGXqokzCV9Ns5raYcQc6dIFUQG0ouq+jyq66g7Wmk8IT/EmP82 u6fqKpW0Dr+18Zxz/uCWY15vVm5mCtSZzdeK+ZGxi5UnJUAFVw7MwrK8bmXT9W5pIHHc vi9g== X-Gm-Message-State: ALoCoQmMPtbSWpWKC1VQziV2/+MXS7sCZKhP53hXxS9xbVrICMGRZjDk/sPfOrefsMe3Z1gi9KMe 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 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-Mailman-Approved-At: Fri, 16 May 2014 07:50:52 +0200 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] =?utf-8?q?=5BPATCH=5D_Fix_for_possible_null_pointer_?= =?utf-8?q?dereference_in_dma=2Ec?= 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: , 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 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()) {