* [PATCH] tty: serial: add error handling for try_module_get
@ 2018-06-12 4:50 Zhouyang Jia
2018-06-12 8:23 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Zhouyang Jia @ 2018-06-12 4:50 UTC (permalink / raw)
Cc: Zhouyang Jia, Jason Wessel, Daniel Thompson, Greg Kroah-Hartman,
Jiri Slaby, kgdb-bugreport, linux-serial, linux-kernel
When try_module_get fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling try_module_get.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
drivers/tty/serial/kgdboc.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
index b4ba2b1..641e22a 100644
--- a/drivers/tty/serial/kgdboc.c
+++ b/drivers/tty/serial/kgdboc.c
@@ -286,8 +286,10 @@ static void kgdboc_pre_exp_handler(void)
con_debug_enter(vc_cons[fg_console].d);
}
/* Increment the module count when the debugger is active */
- if (!kgdb_connected)
- try_module_get(THIS_MODULE);
+ if (!kgdb_connected) {
+ if (!try_module_get(THIS_MODULE))
+ printk(KERN_ERR "kgdboc: cannot get module.\n");
+ }
}
static void kgdboc_post_exp_handler(void)
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tty: serial: add error handling for try_module_get
2018-06-12 4:50 [PATCH] tty: serial: add error handling for try_module_get Zhouyang Jia
@ 2018-06-12 8:23 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2018-06-12 8:23 UTC (permalink / raw)
To: Zhouyang Jia
Cc: Jason Wessel, Daniel Thompson, Greg Kroah-Hartman, Jiri Slaby,
kgdb-bugreport, open list:SERIAL DRIVERS,
Linux Kernel Mailing List
On Tue, Jun 12, 2018 at 7:50 AM, Zhouyang Jia <jiazhouyang09@gmail.com> wrote:
> When try_module_get fails, the lack of error-handling code may
> cause unexpected results.
What results? What is recovery approach here?
How printing message change a behaviour?
> This patch adds error-handling code after calling try_module_get.
> + if (!kgdb_connected) {
> + if (!try_module_get(THIS_MODULE))
> + printk(KERN_ERR "kgdboc: cannot get module.\n");
So, what's wrong with pr_err() ?
> + }
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-12 8:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-12 4:50 [PATCH] tty: serial: add error handling for try_module_get Zhouyang Jia
2018-06-12 8:23 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox