tty: vcc: add check for mdesc_grab()
Subsystems (2)
PATCH 1/1 tty: vcc: add check for mdesc_grab()
In vcc_probe(), we should check the return value of mdesc_grab() as it may return NULL. While the vio_vdev_node() has the NULL-check, but if there is still a call to mdesc_release() which may cause a NPD bug.
--- drivers/tty/vcc.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/tty/vcc.c +3 -0
@@ -610,6 +610,9 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) hp =mdesc_grab (); +if (!hp) +return -ENODEV ; + node =vio_vdev_node (hp, vdev);if (node ==MDESC_NODE_NULL ) { rv = -ENXIO ;
Signature · 1 line
2.25.1
Greg KH
maintainerQuoted 5 lines · Liang He
In
vcc_probe(), we should check the return value ofmdesc_grab()as it may return NULL. While thevio_vdev_node()has the NULL-check, but if there is still a call tomdesc_release()which may cause a NPD bug.
Have you actually triggered this issue? If so, how?
Quoted 11 lines
Fixes 5d171050e28f ("sparc64: vcc: Enable VCC port probe and removal")Signed-off-by Liang He <[email protected]>--- drivers/tty/vcc.c | 3 +++ 1 file changed, 3 insertions(+)drivers/tty/vcc.c +0
-0
drivers/tty/vcc.c static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) · line 614
Quoted 5 lines
drivers/tty/vcc.c +2
-0@@ -610,6 +610,9 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) hp =mdesc_grab (); +if (!hp) +return -ENODEV ;
This change is obviously not correct and has not been tested, sorry. Please do not make changes like this without properly validating them.
greg k-h
Quoted 9 lines · Greg KH
Quoted 5 lines · Liang He
In
vcc_probe(), we should check the return value ofmdesc_grab()as it may return NULL. While thevio_vdev_node()has the NULL-check, but if there is still a call tomdesc_release()which may cause a NPD bug.Have you actually triggered this issue? If so, how?
Hi, Greg,
Thanks very much for your reply.
In fact, I have not actually triggered this issue,
but I indeed meet lots of checks in other *_init functions, e.g., mdesc_adi_init()/ldc_init().
However, if we can make sure the return value can never be NULL
when our kernel execute into these *_probe functions, my patchs are indeed useless.
Thanks and sorry for any potential trouble.
Liang
Quoted 21 lines
Quoted 11 lines
Fixes 5d171050e28f ("sparc64: vcc: Enable VCC port probe and removal")Signed-off-by Liang He <[email protected]>--- drivers/tty/vcc.c | 3 +++ 1 file changed, 3 insertions(+)drivers/tty/vcc.c +0
-0drivers/tty/vcc.c static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) · line 614
Quoted 5 lines
drivers/tty/vcc.c +2
-0@@ -610,6 +610,9 @@ static int vcc_probe(struct vio_dev *vdev, const struct vio_device_id *id) hp =mdesc_grab (); +if (!hp) +return -ENODEV ;This change is obviously not correct and has not been tested, sorry. Please do not make changes like this without properly validating them.
greg k-h