From patchwork Mon May 14 18:50:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 10400101 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 ECA26601E9 for ; Tue, 15 May 2018 07:03:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9ED12860C for ; Tue, 15 May 2018 07:03:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA45428608; Tue, 15 May 2018 07:03:52 +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=-5.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5AB9028608 for ; Tue, 15 May 2018 07:03:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 033486E1A1; Tue, 15 May 2018 07:02:02 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr0-x243.google.com (mail-wr0-x243.google.com [IPv6:2a00:1450:400c:c0c::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 76C106E0F5 for ; Mon, 14 May 2018 18:50:46 +0000 (UTC) Received: by mail-wr0-x243.google.com with SMTP id v5-v6so13424884wrf.9 for ; Mon, 14 May 2018 11:50:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=+Gj/qVgzlXI3uT9KjcF83v7SvQtEDhrbk1NormCD/sA=; b=Hf6tZCnRD8URQ+8z3St75o2zhF+gRCYz6jUNIFRa5CcXK57ESsLGHSP7hdIOGc+Oqj pK4Np/T+UDSDgd+r9WblkAzKp+w0qdv4fS4lTF3ThwwfMOAmwYoimkvFE0kIaAFVn8LO CTKphu65eRjG2DCfyKSzYBtsMXKCpDN/nbrTH98dmjkwKezGu6uM85tzbKbYJVALCFpN nc8pWF5IpxWbvgn+PUh3TJuEG1FKZlj2Qir9Nd/gRj9xOU4yvG/prVVWSFPlXY5j+hAG fjOgWRHl+AgipuV6L2iLn1XqonudJMkpxETKxHr5HaxQJ3l7dqbsPu82r++KLoNLsYw9 Gx3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+Gj/qVgzlXI3uT9KjcF83v7SvQtEDhrbk1NormCD/sA=; b=GQUodEW2WKPfsMm7NcQD81aC9nSyjOlRAI/HTnKoWD0y/pVXbLUE7XS56YUPUTwyMs rcbBM8R9pTOQgedk8EAjVgFU4C/sF5fxTgXXgVijyNuDRma3pI1PaRAWBgdKru33td+z W8g6HrL0RsaaHSIkMvxyHfLTiEfzUJ8wjxwRn5oQtQKfCWJSQSVPMtOr00qcfpZb3+tZ SYViM9Whe1N8ukt1qWNk0KPVdoTuOb+6LjH38Vd7dDS5mfZ6CRO7lT/J5gf+s3hLaEox 5PSO9Bckc5asTa03yN1zSmRYaP+Mc7skI7N04ZBmClkFH6IjhJI3Av6EmTaZtALpY+Lw 7jWQ== X-Gm-Message-State: ALKqPwfyIahIuzkeK4/+x0yB3Cj2HUD1yjZBxiFIOJ28OtYs6T0LNQAA JpOsXnF1qMUW2DG5Lr/CQn4= X-Google-Smtp-Source: AB8JxZoHvFia0+DQUevdWoL+Og4UIlxBoga79F5y8HnREPbNLsh6dhH441jbB2q6jvTRvz+4uNefYw== X-Received: by 2002:adf:ae02:: with SMTP id x2-v6mr7500221wrc.201.1526323844848; Mon, 14 May 2018 11:50:44 -0700 (PDT) Received: from flashbox.your-server.de ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id 67-v6sm10339048wmw.32.2018.05.14.11.50.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 May 2018 11:50:44 -0700 (PDT) From: Nathan Chancellor To: devel@driverdev.osuosl.org Subject: [PATCH] staging: android: ion: Check return value of ion_buffer_kmap_get Date: Mon, 14 May 2018 11:50:44 -0700 Message-Id: <20180514185044.19367-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.17.0 X-Mailman-Approved-At: Tue, 15 May 2018 07:01:55 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Todd Kjos , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Nathan Chancellor , Martijn Coenen MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP GCC warns that vaddr is set but unused. Check the return value of ion_buffer_kmap_get to make vaddr useful and make sure everything is properly configured before beginning a DMA. Suggested-by: Laura Abbott Signed-off-by: Nathan Chancellor --- drivers/staging/android/ion/ion.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index d10b60fe4a29..af682cbde767 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -315,6 +315,7 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, struct ion_buffer *buffer = dmabuf->priv; void *vaddr; struct ion_dma_buf_attachment *a; + int ret = 0; /* * TODO: Move this elsewhere because we don't always need a vaddr @@ -322,6 +323,10 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, if (buffer->heap->ops->map_kernel) { mutex_lock(&buffer->lock); vaddr = ion_buffer_kmap_get(buffer); + if (IS_ERR(vaddr)) { + ret = PTR_ERR(vaddr); + goto unlock; + } mutex_unlock(&buffer->lock); } @@ -330,9 +335,10 @@ static int ion_dma_buf_begin_cpu_access(struct dma_buf *dmabuf, dma_sync_sg_for_cpu(a->dev, a->table->sgl, a->table->nents, direction); } - mutex_unlock(&buffer->lock); - return 0; +unlock: + mutex_unlock(&buffer->lock); + return ret; } static int ion_dma_buf_end_cpu_access(struct dma_buf *dmabuf,