From patchwork Wed May 17 08:15:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Archit Taneja X-Patchwork-Id: 9730381 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 61D5160363 for ; Wed, 17 May 2017 08:16:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52F6928713 for ; Wed, 17 May 2017 08:16:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 479A628715; Wed, 17 May 2017 08:16:07 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, 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 D91C02871E for ; Wed, 17 May 2017 08:16:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 818E88924B; Wed, 17 May 2017 08:16:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id 10F228924B for ; Wed, 17 May 2017 08:16:03 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E872360DAF; Wed, 17 May 2017 08:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1495008962; bh=fBNzH1iK6tLf8ioHOlAH3fGvFJVx1BJdbm00ub5gGDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oen6LgZVuNAcjdIShhso/X7hkTzyUKFF0AUH7nAP0uRDwiJxswU8cWwRoXGHdJQD/ uZIMtMaPhN0qOXDXz+7Cm4h9mhMjZEOAcohJVlR81t4LO1Uvy7DmNz94LiaBE/7bmB rA2ok0sL+qnZeMmJInbxNl+LxWitqXMZutED0pAQ= Received: from localhost (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: architt@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 6208C60DA7; Wed, 17 May 2017 08:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1495008962; bh=fBNzH1iK6tLf8ioHOlAH3fGvFJVx1BJdbm00ub5gGDA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Oen6LgZVuNAcjdIShhso/X7hkTzyUKFF0AUH7nAP0uRDwiJxswU8cWwRoXGHdJQD/ uZIMtMaPhN0qOXDXz+7Cm4h9mhMjZEOAcohJVlR81t4LO1Uvy7DmNz94LiaBE/7bmB rA2ok0sL+qnZeMmJInbxNl+LxWitqXMZutED0pAQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 6208C60DA7 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=architt@codeaurora.org From: Archit Taneja To: labbott@redhat.com, sumit.semwal@linaro.org Subject: [PATCH 3/3] staging: android: ion: Avoid calling free_duped_table() twice Date: Wed, 17 May 2017 13:45:48 +0530 Message-Id: <20170517081548.16413-4-architt@codeaurora.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170517081548.16413-1-architt@codeaurora.org> References: <20170517081548.16413-1-architt@codeaurora.org> Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Currently, the duplicated sg table is freed in the detach() and the error path of map_dma_buf() ion's dma_buf_ops. If a call to dma_buf_map_attachment() fails, the importer is expected to call dma_buf_detach() to remove the attachment. This will result in us trying to free the duped sg table twice. Don't call free_duped_table() in ion_map_dma_buf() to avoid this. Signed-off-by: Archit Taneja --- drivers/staging/android/ion/ion.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/staging/android/ion/ion.c b/drivers/staging/android/ion/ion.c index 90ae6ce466ed..b483e1081309 100644 --- a/drivers/staging/android/ion/ion.c +++ b/drivers/staging/android/ion/ion.c @@ -268,20 +268,14 @@ static struct sg_table *ion_map_dma_buf(struct dma_buf_attachment *attachment, { struct ion_dma_buf_attachment *a = attachment->priv; struct sg_table *table; - int ret; table = a->table; if (!dma_map_sg(attachment->dev, table->sgl, table->nents, - direction)){ - ret = -ENOMEM; - goto err; - } - return table; + direction)) + return ERR_PTR(-ENOMEM); -err: - free_duped_table(table); - return ERR_PTR(ret); + return table; } static void ion_unmap_dma_buf(struct dma_buf_attachment *attachment,