Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp2032219imm; Thu, 24 May 2018 04:51:07 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoZsVf59sIZsZOlf1cRC5H+/oZxc97ClkPyQQERHPqzgoKkYUr5lEkoxMtOvDeBSYWHPXrS X-Received: by 2002:a63:6742:: with SMTP id b63-v6mr5661029pgc.54.1527162667447; Thu, 24 May 2018 04:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527162667; cv=none; d=google.com; s=arc-20160816; b=kb8C/Y3+1cAfzVYkTBLydPUoq32UCYYuenvIzLD5tgSnNWegBS+blA3cTYL9HqDixE QGeMaIw94iwDqgN7QNgSFWW9FfGpJaXNx750fPAV94RyBF7TM+2BD43pueyEB/p7P+vZ 8QFNAsoZb/79DyjbeU7Cmsf3yX1lYXReWj80Aea0CLJuJYjvPkuY61+WE8/T63fQJe9A cL7csdNyl9EQP9a60bWZVGiebdwjuRBsyEtTOQ5O5AEsInvpns5g0hvejyrehk4nVA2z Jnxuu0MY/+IsUEy20v+ktHfsOKkzypCXZS13UIMOdP57WCHT8amVjScBLJVlHH7nfVnE xEZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=+Mk+C4AUJiK2MaVKIK+UygqPtITZHj+jIhozwzF9y6U=; b=aE5J4uKtD8pLdpS7Luu+mHHLWx9sc1dPEfZZE2Dpmb4SCg+b+M7lHwCq0vwd2+a4Os hgDaRWNm6+IsmrygvMTtMa+xCcH7GSjKL6YVg5/M7ISjGdOJzAl72j8UspFLCtKD6Q/O jxxpIwo8fWEDA/06lZeRxUTasTU05vR7nYd49ZpP4XnroQ8KEejEynZqviXQyI6ki+cl o8p/e46TbHzP/9I2V4htLN4hd+50qNWZzAkMmLh7AqWz92xzzYkPvlVlsAMJPqTaqu2e SEQ6cTRQl9YhAL95DLRBouFvYOem0eeK2bdfBY2KaUCbKABkV3xofmh/nnDXH2FSVZHL BQzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BuM041bi; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14-v6si16498083pgv.279.2018.05.24.04.50.52; Thu, 24 May 2018 04:51:07 -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=@kernel.org header.s=default header.b=BuM041bi; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967254AbeEXLuB (ORCPT + 99 others); Thu, 24 May 2018 07:50:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:59116 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966990AbeEXJrB (ORCPT ); Thu, 24 May 2018 05:47:01 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7F7EA20892; Thu, 24 May 2018 09:47:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1527155221; bh=8P4UgpDsE4DQ3SIWpYO9nnitfg+ukCjq9LF4dhcUMbA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BuM041biVZwfMBROGm/cfpyIUyqmjLR1i4urQ5h1XUlFIUMb8aBfllHqKbnY0I/V4 E38q2saRnaqe4vd9xEpDYIBYlTHziNxqfXBbJEPiKy+AZX8r4Z2NjRucAKVUpaJzOG bmmiXC8Nzp87RN6I7x5eIyvJ2pwVWkKzS2oBPvL8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jon Hunter , Vinod Koul , Fabrizio Castro , Jianming Qiao Subject: [PATCH 4.4 87/92] dmaengine: ensure dmaengine helpers check valid callback Date: Thu, 24 May 2018 11:39:04 +0200 Message-Id: <20180524093207.591927770@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180524093159.286472249@linuxfoundation.org> References: <20180524093159.286472249@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Vinod Koul commit 757d12e5849be549076901b0d33c60d5f360269c upstream. dmaengine has various device callbacks and exposes helper functions to invoke these. These helpers should check if channel, device and callback is valid or not before invoking them. Reported-by: Jon Hunter Signed-off-by: Vinod Koul Signed-off-by: Fabrizio Castro Signed-off-by: Jianming Qiao Signed-off-by: Greg Kroah-Hartman --- include/linux/dmaengine.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h @@ -767,6 +767,9 @@ static inline struct dma_async_tx_descri sg_dma_address(&sg) = buf; sg_dma_len(&sg) = len; + if (!chan || !chan->device || !chan->device->device_prep_slave_sg) + return NULL; + return chan->device->device_prep_slave_sg(chan, &sg, 1, dir, flags, NULL); } @@ -775,6 +778,9 @@ static inline struct dma_async_tx_descri struct dma_chan *chan, struct scatterlist *sgl, unsigned int sg_len, enum dma_transfer_direction dir, unsigned long flags) { + if (!chan || !chan->device || !chan->device->device_prep_slave_sg) + return NULL; + return chan->device->device_prep_slave_sg(chan, sgl, sg_len, dir, flags, NULL); } @@ -786,6 +792,9 @@ static inline struct dma_async_tx_descri enum dma_transfer_direction dir, unsigned long flags, struct rio_dma_ext *rio_ext) { + if (!chan || !chan->device || !chan->device->device_prep_slave_sg) + return NULL; + return chan->device->device_prep_slave_sg(chan, sgl, sg_len, dir, flags, rio_ext); } @@ -796,6 +805,9 @@ static inline struct dma_async_tx_descri size_t period_len, enum dma_transfer_direction dir, unsigned long flags) { + if (!chan || !chan->device || !chan->device->device_prep_dma_cyclic) + return NULL; + return chan->device->device_prep_dma_cyclic(chan, buf_addr, buf_len, period_len, dir, flags); } @@ -804,6 +816,9 @@ static inline struct dma_async_tx_descri struct dma_chan *chan, struct dma_interleaved_template *xt, unsigned long flags) { + if (!chan || !chan->device || !chan->device->device_prep_interleaved_dma) + return NULL; + return chan->device->device_prep_interleaved_dma(chan, xt, flags); } @@ -811,7 +826,7 @@ static inline struct dma_async_tx_descri struct dma_chan *chan, dma_addr_t dest, int value, size_t len, unsigned long flags) { - if (!chan || !chan->device) + if (!chan || !chan->device || !chan->device->device_prep_dma_memset) return NULL; return chan->device->device_prep_dma_memset(chan, dest, value, @@ -824,6 +839,9 @@ static inline struct dma_async_tx_descri struct scatterlist *src_sg, unsigned int src_nents, unsigned long flags) { + if (!chan || !chan->device || !chan->device->device_prep_dma_sg) + return NULL; + return chan->device->device_prep_dma_sg(chan, dst_sg, dst_nents, src_sg, src_nents, flags); }