[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20190514152437.35744-1-yuehaibing@huawei.com>
Date: Tue, 14 May 2019 23:24:37 +0800
From: YueHaibing <yuehaibing@...wei.com>
To: <sudipm.mukherjee@...il.com>, <gregkh@...uxfoundation.org>
CC: <linux-kernel@...r.kernel.org>, YueHaibing <yuehaibing@...wei.com>
Subject: [PATCH] parport: Fix mem leak in parport_register_dev_model
BUG: memory leak
unreferenced object 0xffff8881df48cda0 (size 16):
comm "syz-executor.0", pid 5077, jiffies 4295994670 (age 22.280s)
hex dump (first 16 bytes):
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
backtrace:
[<00000000d2d0d5fe>] parport_register_dev_model+0x141/0x6e0 [parport]
[<00000000782f6dab>] 0xffffffffc15d1196
[<00000000d2ca6ae4>] platform_drv_probe+0x7e/0x100
[<00000000628c2a94>] really_probe+0x342/0x4d0
[<000000006874f5da>] driver_probe_device+0x8c/0x170
[<00000000424de37a>] __device_attach_driver+0xda/0x100
[<000000002acab09a>] bus_for_each_drv+0xfe/0x170
[<000000003d9e5f31>] __device_attach+0x190/0x230
[<0000000035d32f80>] bus_probe_device+0x123/0x140
[<00000000a05ba627>] device_add+0x7cc/0xce0
[<000000003f7560bf>] platform_device_add+0x230/0x3c0
[<000000002a0be07d>] 0xffffffffc15d0949
[<000000007361d8d2>] port_check+0x3b/0x50 [parport]
[<000000004d67200f>] bus_for_each_dev+0x115/0x180
[<000000003ccfd11c>] __parport_register_driver+0x1f0/0x210 [parport]
[<00000000987f06fc>] 0xffffffffc15d803e
After commit 4e5a74f1db8d ("parport: Revert "parport: fix
memory leak""), free_pardevice do not free par_dev->state,
we should free it in error path of parport_register_dev_model
before return.
Reported-by: Hulk Robot <hulkci@...wei.com>
Fixes: 4e5a74f1db8d ("parport: Revert "parport: fix memory leak"")
Signed-off-by: YueHaibing <yuehaibing@...wei.com>
---
drivers/parport/share.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/parport/share.c b/drivers/parport/share.c
index 5dc53d4..7b4ee33 100644
--- a/drivers/parport/share.c
+++ b/drivers/parport/share.c
@@ -895,6 +895,7 @@ parport_register_dev_model(struct parport *port, const char *name,
par_dev->devmodel = true;
ret = device_register(&par_dev->dev);
if (ret) {
+ kfree(par_dev->state);
put_device(&par_dev->dev);
goto err_put_port;
}
@@ -912,6 +913,7 @@ parport_register_dev_model(struct parport *port, const char *name,
spin_unlock(&port->physport->pardevice_lock);
pr_debug("%s: cannot grant exclusive access for device %s\n",
port->name, name);
+ kfree(par_dev->state);
device_unregister(&par_dev->dev);
goto err_put_port;
}
--
2.7.4
Powered by blists - more mailing lists