mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 12:43:55 +08:00
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 commit4e5a74f1db
("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:4e5a74f1db
("parport: Revert "parport: fix memory leak"") Signed-off-by: YueHaibing <yuehaibing@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
de9a7f6f5f
commit
1c7ebeabc9
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user