vt: correctly check return value of class_create
PATCH 1/1 vt: correctly check return value of class_create
Since class_create can be failed in memory pressure, its return value should be checked and correctly handled.
Signed-off-by Insu Yun <[email protected]>
--- drivers/tty/vt/vc_screen.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/tty/vt/vc_screen.c +2 -0
@@ -644,6 +644,8 @@ int __init vcs_init(void)if (register_chrdev (VCS_MAJOR ,"vcs" , &vcs_fops))panic ("unable to get major %d for vcs device" ,VCS_MAJOR ); vc_class =class_create (THIS_MODULE ,"vc" ); +if (IS_ERR (vc_class)) +return PTR_ERR (vc_class);device_create (vc_class,NULL ,MKDEV (VCS_MAJOR ,0 ),NULL ,"vcs" );device_create (vc_class,NULL ,MKDEV (VCS_MAJOR ,128 ),NULL ,"vcsa" );
Signature · 1 line
1.9.1
Greg KH
maintainerQuoted 1 line · Insu Yun
Since
class_createcan be failed in memory pressure,
In this case, really? At init time?
Quoted 1 line
its return value should be checked and correctly handled.
You didn't correctly handle it, you leaked memory and other resources :(