linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vt: correctly check return value of class_create
@ 2016-01-23 20:52 Insu Yun
  2016-01-23 23:51 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Insu Yun @ 2016-01-23 20:52 UTC (permalink / raw)
  To: gregkh, jslaby, linux-kernel
  Cc: taesoo, yeongjin.jang, insu, changwoo, Insu Yun

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] vt: correctly check return value of class_create
  2016-01-23 20:52 [PATCH] vt: correctly check return value of class_create Insu Yun
@ 2016-01-23 23:51 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2016-01-23 23:51 UTC (permalink / raw)
  To: Insu Yun; +Cc: jslaby, linux-kernel, taesoo, yeongjin.jang, insu, changwoo

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 :(

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-23 23:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-23 20:52 [PATCH] vt: correctly check return value of class_create Insu Yun
2016-01-23 23:51 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).