From patchwork Mon Sep 24 06:17:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sachin Kamat X-Patchwork-Id: 1496261 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id 91959DF280 for ; Mon, 24 Sep 2012 06:21:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755024Ab2IXGVg (ORCPT ); Mon, 24 Sep 2012 02:21:36 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:41148 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755019Ab2IXGVf (ORCPT ); Mon, 24 Sep 2012 02:21:35 -0400 Received: by padhz1 with SMTP id hz1so712496pad.19 for ; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=qsrSoz8b/TAOSmh4UFQChMQeaDROEp4fyu5qacDaeAs=; b=Nj+aWvnAHblmvtECkKBCn9k9S+TjGK4rcoE+lrZemLORB/DFdimAeVNZo8Q5+OrCOx sh8cjEuoUzZppM17kxipZ6BoIKWQ24SX/IkeIwlj+YPpOEDhvrwni3ui1uft7bGVt1Fq CZeMb9web6hfGFHQSs//0CQSm98YD/YfxcISYK3G3sFMefVpJON9H44oP8bUkHKzM53m m2pTJNY0Ih2MpboDQtdIj1HpVQDNjdx3+ahO3bk1dut+q6iv/CKo86KUWLTWYt4nepUi xRLyq9gF8qKtGXlQf3Ua5CZ9hb9Hayj579uWjMMomtAdO/dsFKOen1k6MqI+u23pE3o1 WkLg== Received: by 10.66.83.129 with SMTP id q1mr30266762pay.4.1348467695047; Sun, 23 Sep 2012 23:21:35 -0700 (PDT) Received: from localhost.localdomain ([115.113.119.130]) by mx.google.com with ESMTPS id ho7sm9161024pbc.3.2012.09.23.23.21.32 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 23 Sep 2012 23:21:34 -0700 (PDT) From: Sachin Kamat To: linux-media@vger.kernel.org Cc: mchehab@infradead.org, sachin.kamat@linaro.org, m.szyprowski@samsung.com, pawel@osciak.com, patches@linaro.org Subject: [PATCH 4/4] [media] mem2mem_testdev: Use devm_kzalloc() in probe Date: Mon, 24 Sep 2012 11:47:48 +0530 Message-Id: <1348467468-19854-4-git-send-email-sachin.kamat@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1348467468-19854-1-git-send-email-sachin.kamat@linaro.org> References: <1348467468-19854-1-git-send-email-sachin.kamat@linaro.org> X-Gm-Message-State: ALoCoQkoFsC7/ySXtRhHvMzhfwVfGNrqDPrgdIbP7lLQEWvb8INR0W8nrOLFdxhiMeCA6GJU0wNR Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org devm_kzalloc() makes error handling and cleanup simpler. Signed-off-by: Sachin Kamat Acked-by: Marek Szyprowski --- drivers/media/platform/mem2mem_testdev.c | 7 ++----- 1 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/mem2mem_testdev.c b/drivers/media/platform/mem2mem_testdev.c index f7d15ec..cd1c844 100644 --- a/drivers/media/platform/mem2mem_testdev.c +++ b/drivers/media/platform/mem2mem_testdev.c @@ -1019,7 +1019,7 @@ static int m2mtest_probe(struct platform_device *pdev) struct video_device *vfd; int ret; - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); if (!dev) return -ENOMEM; @@ -1027,7 +1027,7 @@ static int m2mtest_probe(struct platform_device *pdev) ret = v4l2_device_register(&pdev->dev, &dev->v4l2_dev); if (ret) - goto free_dev; + return ret; atomic_set(&dev->num_inst, 0); mutex_init(&dev->dev_mutex); @@ -1073,8 +1073,6 @@ rel_vdev: video_device_release(vfd); unreg_dev: v4l2_device_unregister(&dev->v4l2_dev); -free_dev: - kfree(dev); return ret; } @@ -1089,7 +1087,6 @@ static int m2mtest_remove(struct platform_device *pdev) del_timer_sync(&dev->timer); video_unregister_device(dev->vfd); v4l2_device_unregister(&dev->v4l2_dev); - kfree(dev); return 0; }