From patchwork Tue Nov 21 04:27:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 10067641 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 DC0CD6022E for ; Tue, 21 Nov 2017 04:28:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2AB0289B2 for ; Tue, 21 Nov 2017 04:28:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7C9128EFA; Tue, 21 Nov 2017 04:28:18 +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_SIGNED, 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 E1385289B2 for ; Tue, 21 Nov 2017 04:28:17 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 00832267650; Tue, 21 Nov 2017 05:28:14 +0100 (CET) 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 5021D267651; Tue, 21 Nov 2017 05:28:13 +0100 (CET) Received: from mail-pg0-f68.google.com (mail-pg0-f68.google.com [74.125.83.68]) by alsa0.perex.cz (Postfix) with ESMTP id 0104B267096 for ; Tue, 21 Nov 2017 05:28:10 +0100 (CET) Received: by mail-pg0-f68.google.com with SMTP id 4so9204795pge.1 for ; Mon, 20 Nov 2017 20:28:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=qq2quQPbpFBz2Clh+IMnBLmA0MPXv1T+F14gprk5XWM=; b=shbLoTV5SibKFXuEQkO2rctDcMfsfzFAH7GdmEZVwAcZqW9qVJm2yUTtibZNbSiV/J jUVuAEuwuaP43DOj6G40IEzrHXRp2hPhZlDoCSSmTMawldnFAVnBASPqmo3INxc+FfiX c7M8yl+GGVyAndOibD5WE2W2FQHX8ubGfZKa90bUhbZ/TOZlcClIuWEpqlZG406COckW rKXX99uALz+SVc5ikg8oDcngxbVRvksvjAdiUU8qnCiAA8EeSfKY0b/oz2XZhnKszgIl aKGeffwRE89dzcLnUP+1n5JYh6XSMXAjK2LeFWWl0HuLGuL9qqyG7IAU/fYgtlTjb4I1 354A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=qq2quQPbpFBz2Clh+IMnBLmA0MPXv1T+F14gprk5XWM=; b=XlUU47IJp6fGgZcD3Vn/NiYB2Sp3cG0mg0nVO0q8JVZTItLF9EsvYNdTacufigGXXq qPqxwGE5B6lgM9vtiJaKw9yj6/s2RL8e7/PV4KnjHh1yNFI1ux1kAKwAUvWk/6HVh8Jw wZe5C+URnFc9z5tnvlKTr/WawZ7ZVrTVLlTPzx/FyDBg2l/Ss9RtdHYLsPCYYQTG0wzn BYe33sgbdXZXykY2217YN0RYSEetg5rPTqTe2yWjUF3qgIePwWdiNe63vIbFdJ4J88Yn vxAt9ISRkVRmUG9j4zgzIvtH38hBavd2fXJ1Jxm/yvjG39dIAWRu4MSwqPhVRcAB60Rd ZYdg== X-Gm-Message-State: AJaThX7O/cxNgAFqsMAiZErHmVpeIjdBSy7oasj/3F1gF2szN4FFO6xz dfOqLj5UgUw8sQRkWD4Brhs= X-Google-Smtp-Source: AGs4zMZRSwpu7DZEzpe7WPWP47fdMiiMBlla2cRVQUB3ZrmtPJzHHI9XZPN/s4QJwtRFK5ZYYPkmOA== X-Received: by 10.84.129.106 with SMTP id 97mr16291345plb.385.1511238489814; Mon, 20 Nov 2017 20:28:09 -0800 (PST) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id t4sm24142546pfj.56.2017.11.20.20.28.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Nov 2017 20:28:08 -0800 (PST) From: Guenter Roeck To: Liam Girdwood Date: Mon, 20 Nov 2017 20:27:56 -0800 Message-Id: <1511238476-10314-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.7.4 Cc: alsa-devel@alsa-project.org, Dominik Behr , linux-kernel@vger.kernel.org, Daniel Kurtz , Takashi Iwai , Mark Brown , Alex Deucher , Guenter Roeck Subject: [alsa-devel] [PATCH] ASoC: amd: Add error checking to probe function 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 acp_audio_dma does not perform sufficient error checking in its probe function. This can result in crashes if a critical error path is encountered. Fixes: 7c31335a03b6a ("ASoC: AMD: add AMD ASoC ACP 2.x DMA driver") Cc: Alex Deucher Cc: Dominik Behr Cc: Daniel Kurtz Signed-off-by: Guenter Roeck Reviewed-by: Alex Deucher --- I didn't add an error check to acp_init() since I was not sure if its return value is ignored on purpose. sound/soc/amd/acp-pcm-dma.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sound/soc/amd/acp-pcm-dma.c b/sound/soc/amd/acp-pcm-dma.c index 9f521a55d610..b5e41df6bb3a 100644 --- a/sound/soc/amd/acp-pcm-dma.c +++ b/sound/soc/amd/acp-pcm-dma.c @@ -1051,6 +1051,11 @@ static int acp_audio_probe(struct platform_device *pdev) struct resource *res; const u32 *pdata = pdev->dev.platform_data; + if (!pdata) { + dev_err(&pdev->dev, "Missing platform data\n"); + return -ENODEV; + } + audio_drv_data = devm_kzalloc(&pdev->dev, sizeof(struct audio_drv_data), GFP_KERNEL); if (audio_drv_data == NULL) @@ -1058,6 +1063,8 @@ static int acp_audio_probe(struct platform_device *pdev) res = platform_get_resource(pdev, IORESOURCE_MEM, 0); audio_drv_data->acp_mmio = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(audio_drv_data->acp_mmio)) + return PTR_ERR(audio_drv_data->acp_mmio); /* The following members gets populated in device 'open' * function. Till then interrupts are disabled in 'acp_init'