Browse Source

usb: phy: drop kfree of devm_kzalloc's data

Using kfree to free data allocated with devm_kzalloc causes double frees.

The Coccinelle semantic patch that fixes this problem is as follows:

// <smpl>
@@
expression x;
@@

x = devm_kzalloc(...)
...
?-kfree(x);
// </smpl>

Reviewed-by: Jingoo Han <jg1.han@samsung.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
Himangi Saraogi 11 years ago
parent
commit
0c5824083b
1 changed files with 1 additions and 3 deletions
  1. 1 3
      drivers/usb/phy/phy-gpio-vbus-usb.c

+ 1 - 3
drivers/usb/phy/phy-gpio-vbus-usb.c

@@ -260,10 +260,8 @@ static int gpio_vbus_probe(struct platform_device *pdev)
 
 
 	gpio_vbus->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
 	gpio_vbus->phy.otg = devm_kzalloc(&pdev->dev, sizeof(struct usb_otg),
 					  GFP_KERNEL);
 					  GFP_KERNEL);
-	if (!gpio_vbus->phy.otg) {
-		kfree(gpio_vbus);
+	if (!gpio_vbus->phy.otg)
 		return -ENOMEM;
 		return -ENOMEM;
-	}
 
 
 	platform_set_drvdata(pdev, gpio_vbus);
 	platform_set_drvdata(pdev, gpio_vbus);
 	gpio_vbus->dev = &pdev->dev;
 	gpio_vbus->dev = &pdev->dev;