diff options
author | YueHaibing <yuehaibing@huawei.com> | 2019-05-14 23:24:37 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-06-25 11:35:55 +0800 |
commit | f9dd0f0928a3883522269db2061bd64d58cec6fc (patch) | |
tree | ae2ff91de9f71c0c7dd0082ea301ffb4781105cb /drivers/parport | |
parent | 4c950c8bb31af39ab74a7a22f88be1d3e8ecd9a3 (diff) | |
download | linux-stable-f9dd0f0928a3883522269db2061bd64d58cec6fc.tar.gz linux-stable-f9dd0f0928a3883522269db2061bd64d58cec6fc.tar.bz2 linux-stable-f9dd0f0928a3883522269db2061bd64d58cec6fc.zip |
parport: Fix mem leak in parport_register_dev_model
[ Upstream commit 1c7ebeabc9e5ee12e42075a597de40fdb9059530 ]
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@huawei.com>
Fixes: 4e5a74f1db8d ("parport: Revert "parport: fix memory leak"")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/parport')
-rw-r--r-- | drivers/parport/share.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/parport/share.c b/drivers/parport/share.c index 5dc53d420ca8..7b4ee33c1935 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; } |