lkml.org 
[lkml]   [1998]   [Sep]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
SubjectBug fix for serial driver
From
Hi Linus,

The following patch fixes a bug in the serial driver where errors in
rs_open() would not correctly decrement the module in-use counter. This
would make it impossible to unload the serial driver after one of these
errors occurred. The patch is quite simple, and easy to see to be
correct. The patch below is against 2.1.117, but it should apply
without any difficulties to the latest kernel.

Could you please apply this for 2.1.120? Thanks!!

- Ted


Patch generated: on Tue Sep 1 00:20:28 EDT 1998 by tytso@rsts-11.mit.edu
against Linux version 2.1.117

===================================================================
RCS file: drivers/char/RCS/ChangeLog,v
retrieving revision 1.1
diff -u -r1.1 drivers/char/ChangeLog
--- drivers/char/ChangeLog 1998/08/27 02:52:58 1.1
+++ drivers/char/ChangeLog 1998/08/27 02:54:55
@@ -1,3 +1,8 @@
+1998-08-26 Theodore Ts'o <tytso@rsts-11.mit.edu>
+
+ * serial.c (rs_open): Correctly decrement the module in-use count
+ on errors.
+
Thu Feb 19 14:24:08 1998 Theodore Ts'o <tytso@rsts-11.mit.edu>

* tty_io.c (tty_name): Remove the non-reentrant (and non-SMP safe)
===================================================================
RCS file: drivers/char/RCS/serial.c,v
retrieving revision 1.1
diff -u -r1.1 drivers/char/serial.c
--- drivers/char/serial.c 1998/08/27 02:49:51 1.1
+++ drivers/char/serial.c 1998/08/27 02:51:36
@@ -2569,15 +2569,21 @@

MOD_INC_USE_COUNT;
line = MINOR(tty->device) - tty->driver.minor_start;
- if ((line < 0) || (line >= NR_PORTS))
+ if ((line < 0) || (line >= NR_PORTS)) {
+ MOD_DEC_USE_COUNT;
return -ENODEV;
+ }
retval = get_async_struct(line, &info);
- if (retval)
+ if (retval) {
+ MOD_DEC_USE_COUNT;
return retval;
+ }
tty->driver_data = info;
info->tty = tty;
- if (serial_paranoia_check(info, tty->device, "rs_open"))
+ if (serial_paranoia_check(info, tty->device, "rs_open")) {
+ MOD_DEC_USE_COUNT;
return -ENODEV;
+ }

#ifdef SERIAL_DEBUG_OPEN
printk("rs_open %s%d, count = %d\n", tty->driver.name, info->line,
@@ -2587,8 +2593,10 @@

if (!tmp_buf) {
page = get_free_page(GFP_KERNEL);
- if (!page)
+ if (!page) {
+ MOD_DEC_USE_COUNT;
return -ENOMEM;
+ }
if (tmp_buf)
free_page(page);
else
@@ -2602,6 +2610,7 @@
(info->flags & ASYNC_CLOSING)) {
if (info->flags & ASYNC_CLOSING)
interruptible_sleep_on(&info->close_wait);
+ MOD_DEC_USE_COUNT;
#ifdef SERIAL_DO_RESTART
return ((info->flags & ASYNC_HUP_NOTIFY) ?
-EAGAIN : -ERESTARTSYS);
@@ -2614,11 +2623,14 @@
* Start up serial port
*/
retval = startup(info);
- if (retval)
+ if (retval) {
+ MOD_DEC_USE_COUNT;
return retval;
+ }

retval = block_til_ready(tty, filp, info);
if (retval) {
+ MOD_DEC_USE_COUNT;
#ifdef SERIAL_DEBUG_OPEN
printk("rs_open returning after block_til_ready with %d\n",
retval);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html

\
 
 \ /
  Last update: 2005-03-22 13:44    [W:0.026 / U:1.916 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site