Since class_create can be failed in memory pressure,
its return value should be checked and correctly handled.

Signed-off-by: Insu Yun <wuni...@gmail.com>
---
 drivers/tty/vt/vc_screen.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/tty/vt/vc_screen.c b/drivers/tty/vt/vc_screen.c
index 14a2b5f..5df4bc1 100644
--- a/drivers/tty/vt/vc_screen.c
+++ b/drivers/tty/vt/vc_screen.c
@@ -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");
-- 
1.9.1

Reply via email to