From patchwork Wed Mar 21 08:30:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Ujfalusi X-Patchwork-Id: 10298951 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 D2E1D600CC for ; Wed, 21 Mar 2018 08:30:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD4E6297A1 for ; Wed, 21 Mar 2018 08:30:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB99C2979D; Wed, 21 Mar 2018 08:30:42 +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.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 67E25297B0 for ; Wed, 21 Mar 2018 08:30:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=qnbgHFkfQ8RxeosYnVoBAtqFXipo2wZUDRZ/yiKemXI=; b=N/AAMjvEjQT6CG TSLqDvCRT1CJ6u4zHC7/I6UyKFuylc0/v/oFJRrNyy1kKUVO5BanxzvKl8gn+GAvoI9Xspy6OmtwJ u335qiyglaPw5511Sh9FHDRZQ7lPwHS1gMpA+IKZro7gItMKeUdrxMXp+Hyi/NnNzsauon91mF5nL csk3O9No48sem0X5Twoe18VFzFbYMgMw7sIl5KRzPimzL5MgY7u26fzwBxDdyUbg4r9HvUREci+Ff tPCb78C9vMhRdJ5Fkx9/GbnErp4NwGtY4DnlSteV4IFDfBHSTDhtgC73grE6j+ZODAlSXNHmQhC4S lPZ0g5ti20a/OTZCXQaQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1eyZ8o-0004Vl-Rg; Wed, 21 Mar 2018 08:30:38 +0000 Received: from fllnx209.ext.ti.com ([198.47.19.16]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1eyZ8l-0004Um-Qu for linux-arm-kernel@lists.infradead.org; Wed, 21 Mar 2018 08:30:37 +0000 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx209.ext.ti.com (8.15.1/8.15.1) with ESMTP id w2L8UHNe028838; Wed, 21 Mar 2018 03:30:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1521621017; bh=xZRC+yumirbBKAbxXXyteq1Bq/v6dvWKKGjYTJRY5YM=; h=From:To:CC:Subject:Date; b=ZkMRY8pr2kxzzdtMv+cIhpiLS59KnO8Kgg1zKS3AppgBYYeGe7YgVVwuGsOgKqb7T RIXaivLZxX/gIhEppatzbezus01+sjLdyjPxqNI6X7qC0Sfoxtr/1C8y22a+uMGmnt COTv/6VN5yyJsVaAEO8OWqsOx45vMxf1KEJ16MqA= Received: from DLEE102.ent.ti.com (dlee102.ent.ti.com [157.170.170.32]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2L8UHSu005089; Wed, 21 Mar 2018 03:30:17 -0500 Received: from DLEE104.ent.ti.com (157.170.170.34) by DLEE102.ent.ti.com (157.170.170.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Wed, 21 Mar 2018 03:30:17 -0500 Received: from dlep32.itg.ti.com (157.170.170.100) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Wed, 21 Mar 2018 03:30:17 -0500 Received: from feketebors.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w2L8UE4x029869; Wed, 21 Mar 2018 03:30:15 -0500 From: Peter Ujfalusi To: Subject: [PATCH] dmaengine: edma: Check the memory allocation for the memcpy dma device Date: Wed, 21 Mar 2018 10:30:22 +0200 Message-ID: <20180321083022.32616-1-peter.ujfalusi@ti.com> X-Mailer: git-send-email 2.16.2 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180321_013036_004140_298ED531 X-CRM114-Status: GOOD ( 14.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dmaengine@vger.kernel.org, dan.j.williams@intel.com, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP If the allocation fails then disable the memcpy support. Signed-off-by: Peter Ujfalusi --- drivers/dma/edma.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index 5b197473106b..519e69e81fca 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c @@ -1899,6 +1899,11 @@ static void edma_dma_init(struct edma_cc *ecc, bool legacy_mode) if (memcpy_channels) { m_ddev = devm_kzalloc(ecc->dev, sizeof(*m_ddev), GFP_KERNEL); + if (!m_ddev) { + dev_warn(ecc->dev, "memcpy is disabled due to OoM\n"); + memcpy_channels = NULL; + goto ch_setup; + } ecc->dma_memcpy = m_ddev; dma_cap_zero(m_ddev->cap_mask); @@ -1926,6 +1931,7 @@ static void edma_dma_init(struct edma_cc *ecc, bool legacy_mode) dev_info(ecc->dev, "memcpy is disabled\n"); } +ch_setup: for (i = 0; i < ecc->num_channels; i++) { struct edma_chan *echan = &ecc->slave_chans[i]; echan->ch_num = EDMA_CTLR_CHAN(ecc->id, i);