From: Johan Hovold Date: Wed, 10 Feb 2016 10:08:29 +0000 (+0100) Subject: greybus: raw: fix memory leak on disconnect X-Git-Tag: v4.9-rc1~119^2~378^2~21^2~712 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=397d34152423d2ddbff3e48495ef988cbb07776b;p=karo-tx-linux.git greybus: raw: fix memory leak on disconnect Make sure the class device is freed as well as deregistered on disconnect. Also deregister the class device before character device as the former depends on the latter. Signed-off-by: Johan Hovold Reviewed-by: Viresh Kumar Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/greybus/raw.c b/drivers/staging/greybus/raw.c index fa5025dd17a3..a6e795996053 100644 --- a/drivers/staging/greybus/raw.c +++ b/drivers/staging/greybus/raw.c @@ -203,9 +203,9 @@ static void gb_raw_connection_exit(struct gb_connection *connection) struct raw_data *temp; // FIXME - handle removing a connection when the char device node is open. + device_destroy(raw_class, raw->dev); cdev_del(&raw->cdev); ida_simple_remove(&minors, MINOR(raw->dev)); - device_del(raw->device); mutex_lock(&raw->list_lock); list_for_each_entry_safe(raw_data, temp, &raw->list, entry) { list_del(&raw_data->entry);