From patchwork Thu Dec 6 22:10:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 1846771 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id CC255400ED for ; Thu, 6 Dec 2012 21:11:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755524Ab2LFVLI (ORCPT ); Thu, 6 Dec 2012 16:11:08 -0500 Received: from mail4-relais-sop.national.inria.fr ([192.134.164.105]:21234 "EHLO mail4-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753057Ab2LFVLH (ORCPT ); Thu, 6 Dec 2012 16:11:07 -0500 X-IronPort-AV: E=Sophos;i="4.84,232,1355094000"; d="scan'208";a="165029376" Received: from palace.lip6.fr (HELO localhost.localdomain) ([132.227.105.202]) by mail4-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 06 Dec 2012 22:10:44 +0100 From: Julia Lawall To: Lauro Ramos Venancio Cc: kernel-janitors@vger.kernel.org, Aloisio Almeida Jr , Samuel Ortiz , linux-wireless@vger.kernel.org, linux-nfc@lists.01.org, linux-kernel@vger.kernel.org Subject: [PATCH] drivers/nfc/nfcwilink.c: use devm_kzalloc Date: Thu, 6 Dec 2012 23:10:40 +0100 Message-Id: <1354831840-21623-1-git-send-email-Julia.Lawall@lip6.fr> X-Mailer: git-send-email 1.7.8.6 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org From: Julia Lawall devm_kzalloc allocates memory that is released when a driver detaches. This patch uses devm_kzalloc for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia Lawall --- drivers/nfc/nfcwilink.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c index 50b1ee4..c7c182d 100644 --- a/drivers/nfc/nfcwilink.c +++ b/drivers/nfc/nfcwilink.c @@ -526,7 +526,7 @@ static int nfcwilink_probe(struct platform_device *pdev) nfc_dev_dbg(&pdev->dev, "probe entry"); - drv = kzalloc(sizeof(struct nfcwilink), GFP_KERNEL); + drv = devm_kzalloc(&pdev->dev, sizeof(struct nfcwilink), GFP_KERNEL); if (!drv) { rc = -ENOMEM; goto exit; @@ -547,7 +547,7 @@ static int nfcwilink_probe(struct platform_device *pdev) if (!drv->ndev) { nfc_dev_err(&pdev->dev, "nci_allocate_device failed"); rc = -ENOMEM; - goto free_exit; + goto exit; } nci_set_parent_dev(drv->ndev, &pdev->dev); @@ -566,9 +566,6 @@ static int nfcwilink_probe(struct platform_device *pdev) free_dev_exit: nci_free_device(drv->ndev); -free_exit: - kfree(drv); - exit: return rc; } @@ -588,8 +585,6 @@ static int nfcwilink_remove(struct platform_device *pdev) nci_unregister_device(ndev); nci_free_device(ndev); - kfree(drv); - dev_set_drvdata(&pdev->dev, NULL); return 0;