mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-05 05:15:23 +02:00
tty: vcc: Add check for kstrdup() in vcc_probe()
Add check for the return value of kstrdup() and return the error, if it fails in order to avoid NULL pointer dereference. Signed-off-by: Yi Yang <yiyang13@huawei.com> Reviewed-by: Jiri Slaby <jirislaby@kernel.org> Link: https://lore.kernel.org/r/20230904035220.48164-1-yiyang13@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
30e945861f
commit
d81ffb87aa
|
@ -579,18 +579,22 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
name = kstrdup(dev_name(&vdev->dev), GFP_KERNEL);
|
name = kstrdup(dev_name(&vdev->dev), GFP_KERNEL);
|
||||||
|
if (!name) {
|
||||||
|
rv = -ENOMEM;
|
||||||
|
goto free_port;
|
||||||
|
}
|
||||||
|
|
||||||
rv = vio_driver_init(&port->vio, vdev, VDEV_CONSOLE_CON, vcc_versions,
|
rv = vio_driver_init(&port->vio, vdev, VDEV_CONSOLE_CON, vcc_versions,
|
||||||
ARRAY_SIZE(vcc_versions), NULL, name);
|
ARRAY_SIZE(vcc_versions), NULL, name);
|
||||||
if (rv)
|
if (rv)
|
||||||
goto free_port;
|
goto free_name;
|
||||||
|
|
||||||
port->vio.debug = vcc_dbg_vio;
|
port->vio.debug = vcc_dbg_vio;
|
||||||
vcc_ldc_cfg.debug = vcc_dbg_ldc;
|
vcc_ldc_cfg.debug = vcc_dbg_ldc;
|
||||||
|
|
||||||
rv = vio_ldc_alloc(&port->vio, &vcc_ldc_cfg, port);
|
rv = vio_ldc_alloc(&port->vio, &vcc_ldc_cfg, port);
|
||||||
if (rv)
|
if (rv)
|
||||||
goto free_port;
|
goto free_name;
|
||||||
|
|
||||||
spin_lock_init(&port->lock);
|
spin_lock_init(&port->lock);
|
||||||
|
|
||||||
|
@ -624,6 +628,11 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id)
|
||||||
goto unreg_tty;
|
goto unreg_tty;
|
||||||
}
|
}
|
||||||
port->domain = kstrdup(domain, GFP_KERNEL);
|
port->domain = kstrdup(domain, GFP_KERNEL);
|
||||||
|
if (!port->domain) {
|
||||||
|
rv = -ENOMEM;
|
||||||
|
goto unreg_tty;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mdesc_release(hp);
|
mdesc_release(hp);
|
||||||
|
|
||||||
|
@ -653,8 +662,9 @@ free_table:
|
||||||
vcc_table_remove(port->index);
|
vcc_table_remove(port->index);
|
||||||
free_ldc:
|
free_ldc:
|
||||||
vio_ldc_free(&port->vio);
|
vio_ldc_free(&port->vio);
|
||||||
free_port:
|
free_name:
|
||||||
kfree(name);
|
kfree(name);
|
||||||
|
free_port:
|
||||||
kfree(port);
|
kfree(port);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user