From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AA93C43219 for ; Mon, 29 Apr 2019 18:45:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 437042067D for ; Mon, 29 Apr 2019 18:45:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729119AbfD2Spu (ORCPT ); Mon, 29 Apr 2019 14:45:50 -0400 Received: from mga06.intel.com ([134.134.136.31]:27294 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728962AbfD2Spu (ORCPT ); Mon, 29 Apr 2019 14:45:50 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Apr 2019 11:45:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,410,1549958400"; d="scan'208";a="153344993" Received: from linux.intel.com ([10.54.29.200]) by FMSMGA003.fm.intel.com with ESMTP; 29 Apr 2019 11:45:49 -0700 Received: from brettjgr-mobl1.ger.corp.intel.com (unknown [10.254.180.216]) by linux.intel.com (Postfix) with ESMTP id A1D445803C2; Mon, 29 Apr 2019 11:45:47 -0700 (PDT) Subject: Re: [PATCH v2] ASoC: Intel: avoid Oops if DMA setup fails To: Ross Zwisler , linux-kernel@vger.kernel.org Cc: Ross Zwisler , Jaroslav Kysela , Jie Yang , Liam Girdwood , Mark Brown , Takashi Iwai , alsa-devel@alsa-project.org, stable@vger.kernel.org References: <20190429182517.210909-1-zwisler@google.com> From: Pierre-Louis Bossart Message-ID: <951de893-e6ff-5bd0-3483-4c1d93b30cfc@linux.intel.com> Date: Mon, 29 Apr 2019 13:45:46 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190429182517.210909-1-zwisler@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On 4/29/19 1:25 PM, Ross Zwisler wrote: > Currently in sst_dsp_new() if we get an error return from sst_dma_new() > we just print an error message and then still complete the function > successfully. This means that we are trying to run without sst->dma > properly set up, which will result in NULL pointer dereference when > sst->dma is later used. This was happening for me in > sst_dsp_dma_get_channel(): > > struct sst_dma *dma = dsp->dma; > ... > dma->ch = dma_request_channel(mask, dma_chan_filter, dsp); > > This resulted in: > > BUG: unable to handle kernel NULL pointer dereference at 0000000000000018 > IP: sst_dsp_dma_get_channel+0x4f/0x125 [snd_soc_sst_firmware] > > Fix this by adding proper error handling for the case where we fail to > set up DMA. > > This change only affects Haswell and Broadwell systems. Baytrail > systems explicilty opt-out of DMA via sst->pdata->resindex_dma_base > being set to -1. > > Signed-off-by: Ross Zwisler > Cc: stable@vger.kernel.org Acked-by: Pierre-Louis Bossart Thanks Ross! FWIW we should start deprecating this driver now and transition to SOF. I'll double-check how the upcoming 1.3 release works on my Pixel 2015/Samus device later this week. > --- > > Changes in v2: > - Upgraded the sst_dma_new() failure message from dev_warn() to dev_err() > (Pierre-Louis). > - Noted in the changelog that this change only affects Haswell and > Broadwell (Pierre-Louis). > > --- > sound/soc/intel/common/sst-firmware.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c > index 1e067504b6043..f830e59f93eaa 100644 > --- a/sound/soc/intel/common/sst-firmware.c > +++ b/sound/soc/intel/common/sst-firmware.c > @@ -1251,11 +1251,15 @@ struct sst_dsp *sst_dsp_new(struct device *dev, > goto irq_err; > > err = sst_dma_new(sst); > - if (err) > - dev_warn(dev, "sst_dma_new failed %d\n", err); > + if (err) { > + dev_err(dev, "sst_dma_new failed %d\n", err); > + goto dma_err; > + } > > return sst; > > +dma_err: > + free_irq(sst->irq, sst); > irq_err: > if (sst->ops->free) > sst->ops->free(sst); >