From: Sudip Mukherjee Date: Thu, 10 Nov 2016 22:11:59 +0000 (+0000) Subject: ppdev: fix memory leak X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=2bd362d5f45c1;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git ppdev: fix memory leak The variable name was only released if parport_register_dev_model() fails. Now that we are using the device-model the parport driver will duplicate the name and use it. So we can release the variable after the device has been registered with the parport. Suggested-by: Arnd Bergmann Signed-off-by: Sudip Mukherjee Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/char/ppdev.c b/drivers/char/ppdev.c index 6af1ce04b3da..f08f3ed98e01 100644 --- a/drivers/char/ppdev.c +++ b/drivers/char/ppdev.c @@ -305,10 +305,10 @@ static int register_device(int minor, struct pp_struct *pp) ppdev_cb.private = pp; pdev = parport_register_dev_model(port, name, &ppdev_cb, minor); parport_put_port(port); + kfree(name); if (!pdev) { printk(KERN_WARNING "%s: failed to register device!\n", name); - kfree(name); return -ENXIO; }