net: ehea: fix possible memory leak in ehea_register_port()
If of_device_register() returns error, the of node and the
name allocated in dev_set_name() is leaked, call put_device()
to give up the reference that was set in device_initialize(),
so that of node is put in logical_port_release() and the name
is freed in kobject_cleanup().
Fixes: 1acf2318dd
("ehea: dynamic add / remove port")
Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
Link: https://lore.kernel.org/r/20221025130011.1071357-1-yangyingliang@huawei.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
8904927312
commit
0e7ce23a91
|
@ -2900,6 +2900,7 @@ static struct device *ehea_register_port(struct ehea_port *port,
|
|||
ret = of_device_register(&port->ofdev);
|
||||
if (ret) {
|
||||
pr_err("failed to register device. ret=%d\n", ret);
|
||||
put_device(&port->ofdev.dev);
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue