From: Johan Hovold Date: Wed, 11 Nov 2015 09:07:05 +0000 (+0100) Subject: greybus: interface: fix potential use-after-free at remove X-Git-Tag: v4.9.8~1233^2~378^2~21^2~1047 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eeb6a6ff597ee47a6ecc652dab769c3137fd1483;p=platform%2Fkernel%2Flinux-rpi3.git greybus: interface: fix potential use-after-free at remove Fix resources (accessible through sysfs) being released before interface is deregistered. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/interface.c b/drivers/staging/greybus/interface.c index 275a8c7..e496b16 100644 --- a/drivers/staging/greybus/interface.c +++ b/drivers/staging/greybus/interface.c @@ -60,6 +60,9 @@ static void gb_interface_release(struct device *dev) { struct gb_interface *intf = to_gb_interface(dev); + kfree(intf->product_string); + kfree(intf->vendor_string); + kfree(intf); } @@ -191,9 +194,6 @@ void gb_interface_remove(struct gb_interface *intf) list_for_each_entry_safe(bundle, next, &intf->bundles, links) gb_bundle_destroy(bundle); - kfree(intf->product_string); - kfree(intf->vendor_string); - module = intf->module; device_unregister(&intf->dev); put_device(&module->dev);