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: 4186291 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 25D1CBFF02 for ; Thu, 15 May 2014 21:57:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4F22C20395 for ; Thu, 15 May 2014 21:57:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 70EE520121 for ; Thu, 15 May 2014 21:57:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756294AbaEOV5P (ORCPT ); Thu, 15 May 2014 17:57:15 -0400 Received: from mail-ee0-f53.google.com ([74.125.83.53]:44518 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756168AbaEOV5N (ORCPT ); Thu, 15 May 2014 17:57:13 -0400 Received: by mail-ee0-f53.google.com with SMTP id c13so1019134eek.40 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=O9OEXTxlOiOCWZHs8ztkfr4S1bQNL6lc8gHQ83mpuH2BMW7LFB8IFT4hUtFPWESqK7 yJclbx7GZQ2wmECLvtUnijhZO0sHfbExe/3YZUj7feHFh1TjO2cxlTOxPyYC8GQdFNDz gmImIUm9woCE9kXRQWkuD2gGEgK3m/Yb5OVq9efUveBSGexIVAbFkAAzG9CHbaSW1cGd RdNJqPCuyY63Q/46Z8h8fmYwj0qZwz150Fx9az+NVPVFIBbyPkWgZ5fMgxoIHlvcUmab U0+glBbXqtm9sSYFB78MjXmff2owVNjezj5/Lac345HrpV1288edjCYDcdm/qVypul+l qqyg== X-Gm-Message-State: ALoCoQnmmgrvHMq5q4zJq2Yp+s6gb0Iaum0DPzd5y0AgALNfHTIf5y6mHYB1VeuXUQ1F8R1+K/kM 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 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: =?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 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 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()) {