From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752093AbdHCWlG (ORCPT ); Thu, 3 Aug 2017 18:41:06 -0400 Received: from vern.gendns.com ([206.190.152.46]:46503 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751736AbdHCWlF (ORCPT ); Thu, 3 Aug 2017 18:41:05 -0400 Subject: Re: [PATCH] drm/tinydrm: mipi-dbi: Fix unbalanced DMA access To: dri-devel@lists.freedesktop.org Cc: =?UTF-8?Q?Noralf_Tr=c3=b8nnes?= , David Airlie , linux-kernel@vger.kernel.org References: <1501618466-32191-1-git-send-email-david@lechnology.com> From: David Lechner Message-ID: <51efe719-566f-6761-9b39-c4cdfdba7a3c@lechnology.com> Date: Thu, 3 Aug 2017 17:41:02 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: <1501618466-32191-1-git-send-email-david@lechnology.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/01/2017 03:14 PM, David Lechner wrote: > If we return here and import_attach is true, then dma_buf_end_cpu_access() > will not be called balance dma_buf_begin_cpu_access(). > > Fix by setting ret instead of returning. > > Signed-off-by: David Lechner > --- > drivers/gpu/drm/tinydrm/mipi-dbi.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/tinydrm/mipi-dbi.c b/drivers/gpu/drm/tinydrm/mipi-dbi.c > index c83eeb7..e10fa4b 100644 > --- a/drivers/gpu/drm/tinydrm/mipi-dbi.c > +++ b/drivers/gpu/drm/tinydrm/mipi-dbi.c > @@ -183,7 +183,8 @@ static int mipi_dbi_buf_copy(void *dst, struct drm_framebuffer *fb, > dev_err_once(fb->dev->dev, "Format is not supported: %s\n", > drm_get_format_name(fb->format->format, > &format_name)); > - return -EINVAL; > + ret = -EINVAL; > + break; > } > > if (import_attach) > I just realized that the next line here can mask ret. if (import_attach) ret = dma_buf_end_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE); So, we should either ignore the return value from dma_buf_end_cpu_access() always or add some logic to ignore it if ret is already an error. In some of the other patches I have been sending, we have the same situation. I those, I have opted to just ignore the return value from dma_buf_end_cpu_access(). e.g... if (import_attach) dma_buf_end_cpu_access(import_attach->dmabuf, DMA_FROM_DEVICE); Is this a reasonable thing to do?