Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp838350pxb; Mon, 16 Aug 2021 19:56:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDsjQBETvowZk//feKDmsHoSRdBIJKymN3v5eQ/+Sw8roG/caCmvje3sYGSE3pe/TnvXAl X-Received: by 2002:a17:906:544f:: with SMTP id d15mr1369371ejp.520.1629168990506; Mon, 16 Aug 2021 19:56:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629168990; cv=none; d=google.com; s=arc-20160816; b=KmLSLEkPYHuOCnuiwZtyMB5mS3T8lBrAklnevqzXkFeG30RhB+izl6a0SMXAyRyIo1 Ky+V3erz+x38HOBy/HxnhlwutCiGRaObt8A7POJADt6KuIBRU1rbQnABDSDKahEoVBEG 46Wt9mJNUm+JYNmM9k2C/duhpziLaNWeXo5b0KOEijPNsSgm7f72/YGyvQDSZbTvjO7M VbQPwdXnwq39RqKH4XFx2Whi+WnddbxzEaBi4junlcz2AvZblBi5Dpp316DdbOWf9+H8 QDJST4n6ee4I8aFz1MYSV7d+WUyyWNKS/0d2oGGWuad6c8vZCnLv6aT1olaGlkT9Sbhq ud2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=NhF9ne4gX2wyjN9NTqRVN2LCp6wtlf7prAXuwoIlnVk=; b=mwT3pNM8JuIExaa3VWq97FL4T9+Jk05U+t0bKzwBwfvaWryOIdIn075v6D5p9fZ9cl 6ybQdyqveE/zdqJXyeCwNjWLFdHSiUmpAsM8OE/0h77Zi/CGvdc13ecF3mmCnM7yfbIx 2cINcz38qahpje27yuf0uK9CGyns9vNBMSKznsjIVCy2yn3Jq2Dx1bx62l3RHoNEuZYQ q3HRSF46ytteB3nscCyVCpr1VG+Ts0Cr+lAuyn1CRRwD4Yxo+Nwn+bnL4dJGhqQvQf7j Qce5VSdNNpSYwDwhcFi1IBOhpgmCcYkEAFXrmdlnzu+b1wiVAX11tfrBHXqxpnqWVVvQ 6T6A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gn9si895544ejc.136.2021.08.16.19.56.06; Mon, 16 Aug 2021 19:56:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233675AbhHQCzO (ORCPT + 99 others); Mon, 16 Aug 2021 22:55:14 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:8030 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233634AbhHQCzN (ORCPT ); Mon, 16 Aug 2021 22:55:13 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GpbGK09NZzYmt0; Tue, 17 Aug 2021 10:54:17 +0800 (CST) Received: from dggpeml500017.china.huawei.com (7.185.36.243) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 10:54:38 +0800 Received: from huawei.com (10.175.103.91) by dggpeml500017.china.huawei.com (7.185.36.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Tue, 17 Aug 2021 10:54:37 +0800 From: Yang Yingliang To: , CC: , , , Subject: [PATCH -next] ASoC: sh: rz-ssi: Fix return value check in rz_ssi_dma_request() Date: Tue, 17 Aug 2021 11:00:27 +0800 Message-ID: <20210817030027.1462671-1-yangyingliang@huawei.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.103.91] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500017.china.huawei.com (7.185.36.243) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In case of error, the function dma_request_chan() returns ERR_PTR() and never returns NULL. Set 'dma_ch' to NULL, if dma_request_chan() returns error, so the code using 'dma_ch' can work correctly. Fixes: 26ac471c5354 ("ASoC: sh: rz-ssi: Add SSI DMAC support") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- sound/soc/sh/rz-ssi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/sound/soc/sh/rz-ssi.c b/sound/soc/sh/rz-ssi.c index ea8d33ede5d2..5ec78fd94d94 100644 --- a/sound/soc/sh/rz-ssi.c +++ b/sound/soc/sh/rz-ssi.c @@ -676,11 +676,17 @@ static void rz_ssi_release_dma_channels(struct rz_ssi_priv *ssi) static int rz_ssi_dma_request(struct rz_ssi_priv *ssi, struct device *dev) { ssi->playback.dma_ch = dma_request_chan(dev, "tx"); + if (IS_ERR(ssi->playback.dma_ch)) + ssi->playback.dma_ch = NULL; ssi->capture.dma_ch = dma_request_chan(dev, "rx"); + if (IS_ERR(ssi->capture.dma_ch)) + ssi->capture.dma_ch = NULL; if (!ssi->playback.dma_ch && !ssi->capture.dma_ch) { ssi->playback.dma_ch = dma_request_chan(dev, "rt"); - if (!ssi->playback.dma_ch) + if (IS_ERR(ssi->playback.dma_ch)) { + ssi->playback.dma_ch = NULL; goto no_dma; + } ssi->dma_rt = true; } -- 2.25.1