Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1315754 > unrolled thread

[PATCH] vt: correctly check return value of class_create

Started byInsu Yun <wuninsu@gmail.com>
First post2016-01-23 22:00 +0100
Last post2016-01-24 01:00 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] vt: correctly check return value of class_create Insu Yun <wuninsu@gmail.com> - 2016-01-23 22:00 +0100
    Re: [PATCH] vt: correctly check return value of class_create Greg KH <gregkh@linuxfoundation.org> - 2016-01-24 01:00 +0100

#1315754 — [PATCH] vt: correctly check return value of class_create

FromInsu Yun <wuninsu@gmail.com>
Date2016-01-23 22:00 +0100
Subject[PATCH] vt: correctly check return value of class_create
Message-ID<qUdrP-8sv-3@gated-at.bofh.it>
Since class_create can be failed in memory pressure,
its return value should be checked and correctly handled.

Signed-off-by: Insu Yun <wuninsu@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

[toc] | [next] | [standalone]


#1315785

FromGreg KH <gregkh@linuxfoundation.org>
Date2016-01-24 01:00 +0100
Message-ID<qUgg2-4Hk-7@gated-at.bofh.it>
In reply to#1315754
On Sat, Jan 23, 2016 at 03:52:46PM -0500, Insu Yun wrote:
> Since class_create can be failed in memory pressure,

In this case, really?  At init time?

> its return value should be checked and correctly handled.

You didn't correctly handle it, you leaked memory and other resources :(

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web