Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp854392yba; Fri, 26 Apr 2019 09:49:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxleEfsVdMsUcgHfrnZ4j16LsRmVFgiC6s4Jbit/F5bhQqhRnC3uxHdAyVWI/kvXt6Scz/k X-Received: by 2002:a17:902:396a:: with SMTP id e39mr46971854plg.220.1556297352210; Fri, 26 Apr 2019 09:49:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556297352; cv=none; d=google.com; s=arc-20160816; b=jkbtf9voPnKSP/rc9r7h/X95+IjmEi3QahsGJg38e+2IfmOorIqBzKvZohl/mbahVo Cl7KvgcdqKShjZcB/6O6OWgjY0/TbTm2BX6oxHXtGn1wh2TFC3xV7u/MTW4nrXsEq6HH CP8WVHWpjR0i+Vg8xr+KAKCZcIi6NStylq7jyOff0sMwG+ssj1oKXh3wrB5H+sig8KiK FbroElaEvyLxaNjIaFDj02jl3G4lU0Q2vOcSsFOn8fsN0jpxzAbghHDlg1XKxumjeORb kaGeplU41/D/5Q5BtmfZLpSD5y9lH53oxXyEnkC/tMfB37jXbVsfSMerz7QM7Re0xS3c FeiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=QqnKyrp3mArwKqL8dFKZ2FJ7oLbcOYhGCMtzg+mpDC0=; b=OtNvr4E2zrgUV00Ru6AQ2Ls0f2r5u0sbcBo3owE9F5oMALf6pJuFzmVCCyJRfFW4F0 nXQ5Y4vxcFkajfKK40S+A3hWOFll40MNPP+o1dBOtluayptcpGuHq6U1FBH70PoLSbtu vw0PwwVbEnvOUMr8J5f1Tmc6lF4cltobp4TwOViaX+M61gUiD1fFpl8vebwGFkulnezm aAZwmpDO0KSST8P5bUnW8QPuuLHEJiUa8DAmWFvx5ibfWHer+8/xRcKBb+p2ZV0KRdtk hwdBkwurQEe9bjj5qumg9GslhKlGEEXuxGjfT6Gvh7m0yndhBTcg1zZT/zPKSfjpq4Vn YGAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dNgKICUg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a13si27064232pfn.70.2019.04.26.09.48.56; Fri, 26 Apr 2019 09:49:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=dNgKICUg; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726394AbfDZQrr (ORCPT + 99 others); Fri, 26 Apr 2019 12:47:47 -0400 Received: from mail-it1-f194.google.com ([209.85.166.194]:52770 "EHLO mail-it1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726167AbfDZQrq (ORCPT ); Fri, 26 Apr 2019 12:47:46 -0400 Received: by mail-it1-f194.google.com with SMTP id x132so6907093itf.2 for ; Fri, 26 Apr 2019 09:47:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QqnKyrp3mArwKqL8dFKZ2FJ7oLbcOYhGCMtzg+mpDC0=; b=dNgKICUg+IWEQxdmdCtJcSez1ZKhkhiV71QuC+EpBG0rrvhfwciZwGars1KO58Cvx7 cC/N/dbiY2Tk8bLLCVEjOPfJTHuhO/BOZBliSuw4Iu67sG25vzU1leEOdJ5g1qvPHpnJ OhqOFs8RWHCLFKgcenGaqdCJZzmSoaQKRVBPs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=QqnKyrp3mArwKqL8dFKZ2FJ7oLbcOYhGCMtzg+mpDC0=; b=GQ5oAWQ8UxL9t77NhOvfucW7W+a5wiFOj4adXaLVv8uZMlRT3qOAU3Q9+YPqRwp5HW E18mkhZzqOuiPwsv69EpvHsSISuUoAlQrVkTCSHwiW9QTq+aQEmiecjHk0S8etdrdU6y 4hLefwb9i160j73EyRXuhf14Iol/y5Rh9mBfIHcJptfFFCmgRkaP11HKkqdum8zO/CL4 aBJ/f2uaBX+WX7PsgnFsGH0eX5FG/zIn3/HolfWrT/IfIphgv3Z3bnaakTgzza4ptZoy Znt/YgZwL5rDIk8XkVi884eKhZyiNwciIn/sMkmU2FxB+ArVt2nDdF+ltGA+OB1FT7xN x2cg== X-Gm-Message-State: APjAAAWBoQKMnsh5GEo6xVXTyXamNSJYK0nm9BdAXRkVkY/Z8fdbpG6b 5v8WcILURLf1ytUaEsW3YSTlzsnd9hPxIw== X-Received: by 2002:a24:2fcb:: with SMTP id j194mr9671987itj.14.1556297265229; Fri, 26 Apr 2019 09:47:45 -0700 (PDT) Received: from localhost ([2620:15c:183:200:855f:8919:84a7:4794]) by smtp.gmail.com with ESMTPSA id q22sm8856679ion.15.2019.04.26.09.47.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Apr 2019 09:47:44 -0700 (PDT) From: Ross Zwisler X-Google-Original-From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , Jaroslav Kysela , Jie Yang , Liam Girdwood , Mark Brown , Pierre-Louis Bossart , Takashi Iwai , alsa-devel@alsa-project.org, stable@vger.kernel.org Subject: [PATCH] ASoC: Intel: avoid Oops if DMA setup fails Date: Fri, 26 Apr 2019 10:47:40 -0600 Message-Id: <20190426164740.211139-1-zwisler@google.com> X-Mailer: git-send-email 2.21.0.593.g511ec345e18-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Signed-off-by: Ross Zwisler Cc: stable@vger.kernel.org --- sound/soc/intel/common/sst-firmware.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/common/sst-firmware.c b/sound/soc/intel/common/sst-firmware.c index 1e067504b6043..9be3a793a55e3 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) + if (err) { dev_warn(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); -- 2.21.0.593.g511ec345e18-goog