From patchwork Thu Oct 4 09:29:57 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Lad, Prabhakar" X-Patchwork-Id: 1545731 Return-Path: X-Original-To: patchwork-davinci@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by patchwork2.kernel.org (Postfix) with ESMTP id 287E6DF238 for ; Thu, 4 Oct 2012 09:32:03 +0000 (UTC) Received: from dlelxv30.itg.ti.com ([172.17.2.17]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id q949UMx2016474; Thu, 4 Oct 2012 04:30:23 -0500 Received: from DLEE74.ent.ti.com (dlee74.ent.ti.com [157.170.170.8]) by dlelxv30.itg.ti.com (8.13.8/8.13.8) with ESMTP id q949UMiV010795; Thu, 4 Oct 2012 04:30:22 -0500 Received: from dlelxv24.itg.ti.com (172.17.1.199) by DLEE74.ent.ti.com (157.170.170.8) with Microsoft SMTP Server id 14.1.323.3; Thu, 4 Oct 2012 04:30:22 -0500 Received: from linux.omap.com (dlelxs01.itg.ti.com [157.170.227.31]) by dlelxv24.itg.ti.com (8.13.8/8.13.8) with ESMTP id q949UMEs007245; Thu, 4 Oct 2012 04:30:22 -0500 Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id 8FDBB80627; Thu, 4 Oct 2012 04:30:22 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp51.itg.ti.com (dflp51.itg.ti.com [128.247.22.94]) by linux.omap.com (Postfix) with ESMTP id 5F9C580626 for ; Thu, 4 Oct 2012 04:30:20 -0500 (CDT) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp51.itg.ti.com (8.13.7/8.13.8) with ESMTP id q949UKPv018055 for ; Thu, 4 Oct 2012 04:30:20 -0500 (CDT) Received: from psmtp.com (na3sys009amx220.postini.com [74.125.149.60]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id q949UJpO023729 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 4 Oct 2012 04:30:19 -0500 Received: from mail-da0-f45.google.com ([209.85.210.45]) (using TLSv1) by na3sys009amx220.postini.com ([74.125.148.10]) with SMTP; Thu, 04 Oct 2012 09:30:19 GMT Received: by mail-da0-f45.google.com with SMTP id n15so158741dad.4 for ; Thu, 04 Oct 2012 02:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=udpcGDBhyLw7vlO8Y59jamwZ6Qfod2Tu1mot9YI4Rjc=; b=DKQMLJtLJeR6kSSQ/pIqffHi87xNHq1aS3kaw2+YQCeYKvBjWu4guOsFtzHY1yiH4d mQwsVl3d6JLTvsj3hVt8IhPzgT0445Wra04PTre1tVRV58tq8zU4bc8PEUGI2ReJaSUu anN2sB6P1p5xukp8TNG1ZLYp38QwQgca0LwxiEEZLG5J0LqTrycW1nisO4D1gChlga0m CWIZELYYrQsQQmgZ9Cb/3tgUseMEehbG05JfVmEcbMvbseDLSKWnQe1HkHPUmIAvreKh XYCkhiSyGKkXNmmqsvxKDDjTFesF2ol6K1CwFrdcS5sbvfy/JzpVuC1oqIN8kRn8O7a9 8hGQ== Received: by 10.68.200.72 with SMTP id jq8mr20189447pbc.38.1349343018816; Thu, 04 Oct 2012 02:30:18 -0700 (PDT) Received: from localhost.localdomain ([122.166.13.141]) by mx.google.com with ESMTPS id py9sm4080935pbb.20.2012.10.04.02.30.11 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Oct 2012 02:30:17 -0700 (PDT) From: Prabhakar To: LMML Subject: [PATCH v2] media: davinci: vpif: Add return code check at vb2_queue_init() Date: Thu, 4 Oct 2012 14:59:57 +0530 Message-ID: <1349342998-31804-1-git-send-email-prabhakar.lad@ti.com> X-Mailer: git-send-email 1.7.4.1 X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:42.54353/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-dkim: 1 skipped:not-enabled X-pstn-settings: 2 (0.5000:0.0050) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [82/3] CC: DLOS , Hans Verkuil , LKML X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com From: Lad, Prabhakar from commit with id 896f38f582730a19eb49677105b4fe4c0270b82e it's mandatory to check the return code of vb2_queue_init(). Signed-off-by: Lad, Prabhakar Signed-off-by: Manjunath Hadli Cc: Hans Verkuil Acked-by: Hans Verkuil --- Changes for v2: 1: Added vb2_dma_contig_cleanup_ctx() on failure of vb2_queue_init() to avoid memory leak, pointed by Hans. drivers/media/platform/davinci/vpif_capture.c | 9 +++++++-- drivers/media/platform/davinci/vpif_display.c | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 83b80ba..cabd5a2 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -976,6 +976,7 @@ static int vpif_reqbufs(struct file *file, void *priv, struct common_obj *common; u8 index = 0; struct vb2_queue *q; + int ret; vpif_dbg(2, debug, "vpif_reqbufs\n"); @@ -1015,8 +1016,12 @@ static int vpif_reqbufs(struct file *file, void *priv, q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct vpif_cap_buffer); - vb2_queue_init(q); - + ret = vb2_queue_init(q); + if (ret) { + vpif_err("vpif_capture: vb2_queue_init() failed\n"); + vb2_dma_contig_cleanup_ctx(common->alloc_ctx); + return ret; + } /* Set io allowed member of file handle to TRUE */ fh->io_allowed[index] = 1; /* Increment io usrs member of channel object to 1 */ diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index ae8329d..7f20ca5 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c @@ -936,6 +936,7 @@ static int vpif_reqbufs(struct file *file, void *priv, enum v4l2_field field; struct vb2_queue *q; u8 index = 0; + int ret; /* This file handle has not initialized the channel, It is not allowed to do settings */ @@ -981,8 +982,12 @@ static int vpif_reqbufs(struct file *file, void *priv, q->mem_ops = &vb2_dma_contig_memops; q->buf_struct_size = sizeof(struct vpif_disp_buffer); - vb2_queue_init(q); - + ret = vb2_queue_init(q); + if (ret) { + vpif_err("vpif_display: vb2_queue_init() failed\n"); + vb2_dma_contig_cleanup_ctx(common->alloc_ctx); + return ret; + } /* Set io allowed member of file handle to TRUE */ fh->io_allowed[index] = 1; /* Increment io usrs member of channel object to 1 */