]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.49/driver-core-bus-fix-a-potential-double-free.patch
4.14-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.9.49 / driver-core-bus-fix-a-potential-double-free.patch
CommitLineData
a1e97e95
GKH
1From 0f9b011d3321ca1079c7a46c18cb1956fbdb7bcb Mon Sep 17 00:00:00 2001
2From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
3Date: Tue, 29 Aug 2017 21:23:49 +0200
4Subject: driver core: bus: Fix a potential double free
5
6From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
7
8commit 0f9b011d3321ca1079c7a46c18cb1956fbdb7bcb upstream.
9
10The .release function of driver_ktype is 'driver_release()'.
11This function frees the container_of this kobject.
12
13So, this memory must not be freed explicitly in the error handling path of
14'bus_add_driver()'. Otherwise a double free will occur.
15
16Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
17Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
18
19---
20 drivers/base/bus.c | 2 +-
21 1 file changed, 1 insertion(+), 1 deletion(-)
22
23--- a/drivers/base/bus.c
24+++ b/drivers/base/bus.c
25@@ -736,7 +736,7 @@ int bus_add_driver(struct device_driver
26
27 out_unregister:
28 kobject_put(&priv->kobj);
29- kfree(drv->p);
30+ /* drv->p is freed in driver_release() */
31 drv->p = NULL;
32 out_put_bus:
33 bus_put(bus);