From patchwork Tue Jul 26 19:28:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 9248759 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 768A96077C for ; Tue, 26 Jul 2016 19:29:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60D6426222 for ; Tue, 26 Jul 2016 19:29:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 53A8E271FD; Tue, 26 Jul 2016 19:29:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14C1F26222 for ; Tue, 26 Jul 2016 19:29:01 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7925C265921; Tue, 26 Jul 2016 21:28:59 +0200 (CEST) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EF01F265558; Tue, 26 Jul 2016 21:28:51 +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 9C7E626568F; Tue, 26 Jul 2016 21:28:50 +0200 (CEST) Received: from mail-pa0-f66.google.com (mail-pa0-f66.google.com [209.85.220.66]) by alsa0.perex.cz (Postfix) with ESMTP id 5D14D26549C for ; Tue, 26 Jul 2016 21:28:43 +0200 (CEST) Received: by mail-pa0-f66.google.com with SMTP id cf3so413313pad.2 for ; Tue, 26 Jul 2016 12:28:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=IZERlTVmpAXj/n3iNqIvqpMmigQJ3Zu9xgbYnZZ5J4E=; b=DaLhHpcii5Pqmes1gHpW2TO+ZHaG/al6HDTQJ1Wdj47nBfLYfUXSr0rrRiPsPiHKey Sxg1hfjOy0GytBvb6eZRO6vAdo7STVvs7ytvX+1SusdwUZpMOD0Xygiu6hEKBhBaEKoy hRLXkT/LWSjohgshCz/L7kM/7vQ2tPfuxpb6iblFmLgW4cVcqucntLXKyEm7QW1pUet0 67kWx00sJoBJjbQhBjPCoxtW7j9mNqeAmt4hLbbA1xgVWVs6PNN4Kd27l1ym4Ga2IEF1 Pb82xs5bRqwAm/2u7BEq5sAK6gJUVtkYKyAzO6vGU7lSCh9Nx9OdoclAILto+u2zsQRZ swyA== 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=IZERlTVmpAXj/n3iNqIvqpMmigQJ3Zu9xgbYnZZ5J4E=; b=aQI388gi3YpVqLnsb/naWKHA3lAUHoIAhiglloPMRFdxgZ/kmYRezgGL74QIx1DZid Un/Sw1IQbWvJBGE59XRgvcLsIIr0qACm7986zPN4FhO+eyn4HiRW7m62DONsHvrdqigp Jc6a5Xoy80J4Jl2sB3dOaEqLQKogcsgL8DqjzVawR3n4wyxo0cWyALIxdd347PzcJkL6 5Iz076zctrwOtQfrQMicKXlJ00dDBnXbks1+SIwqkP2FamRKl495jRGksarXShRXTI0i j0EQNCV+v1IlzRzNl8vh9ngyhBvKGG3y+fZEmE1mTre6c1uuiPudPMsRYeQ2AQ2Tikr9 dtBg== X-Gm-Message-State: AEkooutP+hZRQ1U3fOMASOrx2VLuPkOR0BQxQ2jL9p5imWctdWR3n3oEMw6rXKCB3AN9bw== X-Received: by 10.66.193.7 with SMTP id hk7mr26513415pac.78.1469561321749; Tue, 26 Jul 2016 12:28:41 -0700 (PDT) Received: from Asurada-Nvidia.nvidia.com (searspoint.nvidia.com. [216.228.112.21]) by smtp.gmail.com with ESMTPSA id c7sm3428570pfj.25.2016.07.26.12.28.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jul 2016 12:28:41 -0700 (PDT) From: Nicolin Chen To: broonie@kernel.org Date: Tue, 26 Jul 2016 12:28:40 -0700 Message-Id: <1469561320-31853-1-git-send-email-nicoleotsuka@gmail.com> X-Mailer: git-send-email 2.1.4 Cc: alsa-devel@alsa-project.org, lgirdwood@gmail.com, linux-kernel@vger.kernel.org Subject: [alsa-devel] [PATCH] ASoC: dapm: Add a dummy snd_pcm_runtime to avoid NULL pointer access 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP The SND_SOC_DAPM_PRE_PMU case would call startup()/hw_params() that might access substream->runtime through other functions. For example: Unable to handle kernel NULL pointer dereference at virtual address [....] PC is at snd_pcm_hw_rule_add+0x24/0x1b0 LR is at snd_pcm_hw_constraint_list+0x20/0x28 [....] Process arecord (pid: 424, stack limit = 0xffffffc1ecaf0020) Call trace: [] snd_pcm_hw_rule_add+0x24/0x1b0 [] snd_pcm_hw_constraint_list+0x20/0x28 [] cs53l30_pcm_startup+0x24/0x30 [] snd_soc_dai_link_event+0x290/0x354 [] dapm_seq_check_event.isra.31+0x134/0x2c8 [] dapm_seq_run_coalesced+0x94/0x1c8 [] dapm_seq_run+0xa4/0x404 [] dapm_power_widgets+0x524/0x984 [] snd_soc_dapm_stream_event+0x8c/0xa8 [] soc_pcm_prepare+0x10c/0x1ec [] snd_pcm_do_prepare+0x1c/0x38 [] snd_pcm_action_single+0x40/0x88 [] snd_pcm_action_nonatomic+0x70/0x90 [] snd_pcm_common_ioctl1+0xb6c/0xdd8 [] snd_pcm_capture_ioctl1+0x200/0x334 [] snd_pcm_ioctl_compat+0x648/0x95c [] compat_SyS_ioctl+0xac/0xfc4 [] el0_svc_naked+0x24/0x28 ---[ end trace 0dc4f99c2759c35c ]--- So this patch adds a dummy runtime for the original dummy substream to merely avoid the NULL pointer access. Signed-off-by: Nicolin Chen --- sound/soc/soc-dapm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 8698c26..eed15ca 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3493,6 +3493,7 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, const struct snd_soc_pcm_stream *config = w->params + w->params_select; struct snd_pcm_substream substream; struct snd_pcm_hw_params *params = NULL; + struct snd_pcm_runtime runtime; u64 fmt; int ret; @@ -3540,6 +3541,8 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, = config->channels_max; memset(&substream, 0, sizeof(substream)); + memset(&runtime, 0, sizeof(runtime)); + substream.runtime = &runtime; switch (event) { case SND_SOC_DAPM_PRE_PMU: