lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1423817530-7745-1-git-send-email-kiran.padwal@smartplayin.com>
Date:	Fri, 13 Feb 2015 14:22:10 +0530
From:	Kiran Padwal <kiran.padwal@...rtplayin.com>
To:	Mauro Carvalho Chehab <mchehab@....samsung.com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Hans Verkuil <hans.verkuil@...co.com>,
	Jingoo Han <jg1.han@...sung.com>,
	Sakari Ailus <sakari.ailus@....fi>, prabhakar.csengg@...il.com,
	Jon Mason <jdmason@...zu.us>,
	Dan Carpenter <dan.carpenter@...cle.com>,
	linux-media@...r.kernel.org, devel@...verdev.osuosl.org,
	linux-kernel@...r.kernel.org,
	Kiran Padwal <kiran.padwal21@...il.com>,
	Kiran Padwal <kiran.padwal@...rtplayin.com>
Subject: [PATCH] [media] staging: dt3155v4l: Switch to using managed resource with devm_

This patch uses managed resource APIs to allocate memory
in order to simplify the driver unload or failure cases

Signed-off-by: Kiran Padwal <kiran.padwal@...rtplayin.com>
---
 drivers/staging/media/dt3155v4l/dt3155v4l.c |   13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/staging/media/dt3155v4l/dt3155v4l.c b/drivers/staging/media/dt3155v4l/dt3155v4l.c
index 293ffda..e60a53e 100644
--- a/drivers/staging/media/dt3155v4l/dt3155v4l.c
+++ b/drivers/staging/media/dt3155v4l/dt3155v4l.c
@@ -901,14 +901,13 @@ dt3155_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	err = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32));
 	if (err)
 		return -ENODEV;
-	pd = kzalloc(sizeof(*pd), GFP_KERNEL);
+	pd = devm_kzalloc(&pdev->dev, sizeof(*pd), GFP_KERNEL);
 	if (!pd)
 		return -ENOMEM;
 	pd->vdev = video_device_alloc();
-	if (!pd->vdev) {
-		err = -ENOMEM;
-		goto err_video_device_alloc;
-	}
+	if (!pd->vdev)
+		return -ENOMEM;
+
 	*pd->vdev = dt3155_vdev;
 	pci_set_drvdata(pdev, pd);    /* for use in dt3155_remove() */
 	video_set_drvdata(pd->vdev, pd);  /* for use in video_fops */
@@ -951,8 +950,7 @@ err_req_region:
 	pci_disable_device(pdev);
 err_enable_dev:
 	video_device_release(pd->vdev);
-err_video_device_alloc:
-	kfree(pd);
+
 	return err;
 }
 
@@ -970,7 +968,6 @@ dt3155_remove(struct pci_dev *pdev)
 	 * video_device_release() is invoked automatically
 	 * see: struct video_device dt3155_vdev
 	 */
-	kfree(pd);
 }
 
 static const struct pci_device_id pci_ids[] = {
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ