From patchwork Tue Aug 14 15:34:36 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Stanislawski X-Patchwork-Id: 10735 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id E04F123F34 for ; Tue, 14 Aug 2012 15:36:09 +0000 (UTC) Received: from mail-yw0-f52.google.com (mail-yw0-f52.google.com [209.85.213.52]) by fiordland.canonical.com (Postfix) with ESMTP id 9AB0CA18A29 for ; Tue, 14 Aug 2012 15:36:09 +0000 (UTC) Received: by yhpp61 with SMTP id p61so615131yhp.11 for ; Tue, 14 Aug 2012 08:36:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:x-auditid :from:to:date:message-id:x-mailer:in-reply-to:references :x-brightmail-tracker:x-tm-as-mml:cc:subject:x-beenthere :x-mailman-version:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-gm-message-state; bh=u90cCNedLLwyDC3xiSlzooHq5iT6IeLNRcrg2ljcaXM=; b=h8dpDAJQ3yLmn+0MhozSsr8ixjH+ZUhGEetCCGi34Xnl9fCJ/9+ynId7EBhwogr3Rp rlO7RSOCPXohUqS69NUdWPotpUMA6K76+p8S5A7NWPDbKQzJ/57azH1hZ1FrbELcLfoA jC75FFye9wAfsEgoDsAdr2hxsIP7Rd+ipr83EdMsSooXGbdU3jMgOoIlXKPVE2lAjuEu djJJujGr6Ocvc63J1ATpOjj3UOyTUwgaWVHwYmL9Ncqp/XAk0olWVJvcksOhUZDSlZAn vAzSAjHoiN8HpcbnKxPj7Nzw1hAJZZdsKEo070cceP9jSTwF2S1E7r4mF3DPvQP7stFg xnLQ== Received: by 10.50.186.131 with SMTP id fk3mr12632280igc.31.1344958568252; Tue, 14 Aug 2012 08:36:08 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.200 with SMTP id ew8csp20579igc; Tue, 14 Aug 2012 08:36:07 -0700 (PDT) Received: by 10.205.127.72 with SMTP id gz8mr4888155bkc.121.1344958567010; Tue, 14 Aug 2012 08:36:07 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id hy16si4078303bkc.19.2012.08.14.08.36.05; Tue, 14 Aug 2012 08:36:06 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T1JA4-00086E-EK; Tue, 14 Aug 2012 15:36:04 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1T1JA2-00085c-4M for linaro-mm-sig@lists.linaro.org; Tue, 14 Aug 2012 15:36:02 +0000 Received: from epcpsbgm2.samsung.com (mailout1.samsung.com [203.254.224.24]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0M8R003XF4O0BPE0@mailout1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 15 Aug 2012 00:36:01 +0900 (KST) X-AuditID: cbfee61b-b7faf6d00000476a-b5-502a706002a0 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 98.C9.18282.0607A205; Wed, 15 Aug 2012 00:36:00 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0M8R004J44MBC810@mmp1.samsung.com> for linaro-mm-sig@lists.linaro.org; Wed, 15 Aug 2012 00:36:00 +0900 (KST) From: Tomasz Stanislawski To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org Date: Tue, 14 Aug 2012 17:34:36 +0200 Message-id: <1344958496-9373-7-git-send-email-t.stanislaws@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> References: <1344958496-9373-1-git-send-email-t.stanislaws@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAd2EAq0AgzszrSy+XHnI5MDocfvf Y+YAxigum5TUnMyy1CJ9uwSujGmP/jEVLBeomHq6h62BcQ1vFyMnh4SAicTU/wuZIWwxiQv3 1rN1MXJxCAksYpSYsWYuO4Szlkni8teZ7CBVbEAdx5Z8ZgSxRQQcJE7fncUMUsQscIhZYn/v a7AiYYFoid51/9hAbBYBVYnJC36ANfAKuEt0rXvKCrFOXuLp/T6wGk4BD4mXm7qBajiAtrlL LPzpP4GRdwEjwypG0dSC5ILipPRcI73ixNzi0rx0veT83E2MYK8/k97BuKrB4hCjAAejEg9v YaJmgBBrYllxZe4hRgkOZiUR3qIgrQAh3pTEyqrUovz4otKc1OJDjNIcLErivCbeX/2FBNIT S1KzU1MLUotgskwcnFINjLUuTnnuVzgOLlpec/Rig8PLmPUz9s5awvdBL2aFRWdJR4dzQLlE zZFj5f27eeSj9whwea88v8L92MTX5+9ZinhsLvl38V7T+pea+66EH2m9bmvJXvI3iFUr1PyA 7/nY+qKtTsHZrEJ2WVv/6TulX9K7NG27oGiQfefmT2rty+t/CvUxc6YYKbEUZyQaajEXFScC AI2tVQD2AQAA X-TM-AS-MML: No Cc: k.debski@samsung.com, pawel@osciak.com, sumit.semwal@ti.com, mchehab@redhat.com, robdclark@gmail.com, linaro-mm-sig@lists.linaro.org, kyungmin.park@samsung.com, dmitriyz@google.com, laurent.pinchart@ideasonboard.com, s.nawrocki@samsung.com, airlied@redhat.com, remi@remlab.net, g.liakhovetski@gmx.de Subject: [Linaro-mm-sig] [PATCHv8 06/26] v4l: vb2-dma-contig: remove reference of alloc_ctx from a buffer X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQmUywXWx6CUETQQ6t5C+H85/6pjiNqECfnHi6HRYGe5uxYIyNPtJlVZMNUZBPA/wl4tzL8i This patch removes a reference to alloc_ctx from an instance of a DMA contiguous buffer. It helps to avoid a risk of a dangling pointer if the context is released while the buffer is still valid. Moreover it removes one dereference step while accessing a device structure. Signed-off-by: Tomasz Stanislawski Signed-off-by: Kyungmin Park Acked-by: Laurent Pinchart --- drivers/media/video/videobuf2-dma-contig.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/media/video/videobuf2-dma-contig.c b/drivers/media/video/videobuf2-dma-contig.c index a05784f..20c95da 100644 --- a/drivers/media/video/videobuf2-dma-contig.c +++ b/drivers/media/video/videobuf2-dma-contig.c @@ -23,7 +23,7 @@ struct vb2_dc_conf { }; struct vb2_dc_buf { - struct vb2_dc_conf *conf; + struct device *dev; void *vaddr; dma_addr_t dma_addr; unsigned long size; @@ -37,22 +37,21 @@ static void vb2_dc_put(void *buf_priv); static void *vb2_dc_alloc(void *alloc_ctx, unsigned long size) { struct vb2_dc_conf *conf = alloc_ctx; + struct device *dev = conf->dev; struct vb2_dc_buf *buf; buf = kzalloc(sizeof *buf, GFP_KERNEL); if (!buf) return ERR_PTR(-ENOMEM); - buf->vaddr = dma_alloc_coherent(conf->dev, size, &buf->dma_addr, - GFP_KERNEL); + buf->vaddr = dma_alloc_coherent(dev, size, &buf->dma_addr, GFP_KERNEL); if (!buf->vaddr) { - dev_err(conf->dev, "dma_alloc_coherent of size %ld failed\n", - size); + dev_err(dev, "dma_alloc_coherent of size %ld failed\n", size); kfree(buf); return ERR_PTR(-ENOMEM); } - buf->conf = conf; + buf->dev = dev; buf->size = size; buf->handler.refcount = &buf->refcount; @@ -69,7 +68,7 @@ static void vb2_dc_put(void *buf_priv) struct vb2_dc_buf *buf = buf_priv; if (atomic_dec_and_test(&buf->refcount)) { - dma_free_coherent(buf->conf->dev, buf->size, buf->vaddr, + dma_free_coherent(buf->dev, buf->size, buf->vaddr, buf->dma_addr); kfree(buf); }