From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757451Ab0FAUxm (ORCPT ); Tue, 1 Jun 2010 16:53:42 -0400 Received: from moutng.kundenserver.de ([212.227.17.8]:55455 "EHLO moutng.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757435Ab0FAUxk (ORCPT ); Tue, 1 Jun 2010 16:53:40 -0400 From: Arnd Bergmann To: Greg KH Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Alan Cox , Frederic Weisbecker , John Kacur , Alan Cox Subject: [PATCH 04/31] isicom: kill off the BKL Date: Tue, 1 Jun 2010 22:52:44 +0200 Message-Id: <1275425591-8803-5-git-send-email-arnd@arndb.de> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1275425591-8803-1-git-send-email-arnd@arndb.de> References: <1275425591-8803-1-git-send-email-arnd@arndb.de> X-Provags-ID: V01U2FsdGVkX1/hrmm3kw+nqOvcA0EeLA7PCDzVFrFjlGUvpnU CeSkRgCeNZKLqNCNJ9kusd3GCfrGRzX8cZ5Pr2o81LDIG+g0x4 i+EPWrKgTCiApzhmotPTQ== Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alan Cox As with the others we can use the port mutex to get the needed locking properties and fix the race with open. Signed-off-by: Alan Cox --- drivers/char/isicom.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index 98310e1..c27e9d2 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c @@ -124,7 +124,6 @@ #include #include #include -#include #include #include #include @@ -872,7 +871,6 @@ static struct tty_port *isicom_find_port(struct tty_struct *tty) static int isicom_open(struct tty_struct *tty, struct file *filp) { struct isi_port *port; - struct isi_board *card; struct tty_port *tport; tport = isicom_find_port(tty); @@ -1118,8 +1116,7 @@ static int isicom_set_serial_info(struct tty_struct *tty, if (copy_from_user(&newinfo, info, sizeof(newinfo))) return -EFAULT; - lock_kernel(); - + mutex_lock(&port->port.mutex); reconfig_port = ((port->port.flags & ASYNC_SPD_MASK) != (newinfo.flags & ASYNC_SPD_MASK)); @@ -1128,7 +1125,7 @@ static int isicom_set_serial_info(struct tty_struct *tty, (newinfo.closing_wait != port->port.closing_wait) || ((newinfo.flags & ~ASYNC_USR_MASK) != (port->port.flags & ~ASYNC_USR_MASK))) { - unlock_kernel(); + mutex_unlock(&port->port.mutex); return -EPERM; } port->port.flags = ((port->port.flags & ~ASYNC_USR_MASK) | @@ -1145,7 +1142,7 @@ static int isicom_set_serial_info(struct tty_struct *tty, isicom_config_port(tty); spin_unlock_irqrestore(&port->card->card_lock, flags); } - unlock_kernel(); + mutex_unlock(&port->port.mutex); return 0; } @@ -1154,7 +1151,7 @@ static int isicom_get_serial_info(struct isi_port *port, { struct serial_struct out_info; - lock_kernel(); + mutex_lock(&port->port.mutex); memset(&out_info, 0, sizeof(out_info)); /* out_info.type = ? */ out_info.line = port - isi_ports; @@ -1164,7 +1161,7 @@ static int isicom_get_serial_info(struct isi_port *port, /* out_info.baud_base = ? */ out_info.close_delay = port->port.close_delay; out_info.closing_wait = port->port.closing_wait; - unlock_kernel(); + mutex_unlock(&port->port.mutex); if (copy_to_user(info, &out_info, sizeof(out_info))) return -EFAULT; return 0; -- 1.7.0.4