Thread (2 messages) 2 messages, 2 authors, 2015-02-27

Re: [PATCH] hso: add missing spinlock grab when iterating the serial table

From: Aleksander Morgado <hidden>
Date: 2015-02-27 20:11:38

On Fri, Feb 27, 2015 at 7:44 PM, Aleksander Morgado
[off-list ref] wrote:
quoted hunk ↗ jump to hunk
Access to the 'serial_table' array needs to be protected by the spinlock.

Signed-off-by: Aleksander Morgado <redacted>
---
 drivers/net/usb/hso.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 3c8dfe5..4f6deff 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -607,19 +607,24 @@ static struct hso_serial *get_serial_by_shared_int_and_type(
                                        struct hso_shared_int *shared_int,
                                        int mux)
 {
+       struct hso_serial *serial = NULL;
        int i, port;
+       unsigned long flags;

        port = hso_mux_to_port(mux);

+       spin_lock_irqsave(&serial_table_lock, flags);
        for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
                if (serial_table[i] &&
                    (dev2ser(serial_table[i])->shared_int == shared_int) &&
                    ((serial_table[i]->port_spec & HSO_PORT_MASK) == port)) {
-                       return dev2ser(serial_table[i]);
+                       serial = dev2ser(serial_table[i]);
+                       break;
                }
        }
+       spin_unlock_irqrestore(&serial_table_lock, flags);

-       return NULL;
+       return serial;
 }

 static struct hso_serial *get_serial_by_index(unsigned index)
--
2.3.1
Seems there are actually more places where this has to be done; I'll
send an updated version of the patch.


-- 
Aleksander
https://aleksander.es
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help