Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755029AbaJMNws (ORCPT ); Mon, 13 Oct 2014 09:52:48 -0400 Received: from 251.110.2.81.in-addr.arpa ([81.2.110.251]:55622 "EHLO lxorguk.ukuu.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754992AbaJMNwp (ORCPT ); Mon, 13 Oct 2014 09:52:45 -0400 Date: Mon, 13 Oct 2014 14:52:29 +0100 From: One Thousand Gnomes To: Ricardo Ribalda Delgado Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org, Nicolas Ferre , Greg Kroah-Hartman , Jiri Slaby Subject: Re: [PATCH] tty/serial_core: Introduce lock mechanism for RS485 Message-ID: <20141013145229.4849f07a@alan.etchedpixels.co.uk> In-Reply-To: <1412948280-30993-1-git-send-email-ricardo.ribalda@gmail.com> References: <1412948280-30993-1-git-send-email-ricardo.ribalda@gmail.com> Organization: Intel Corporation X-Mailer: Claws Mail 3.9.3 (GTK+ 2.24.23; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > @@ -1154,8 +1154,16 @@ static int uart_get_icount(struct tty_struct *tty, > static int uart_get_rs485_config(struct uart_port *port, > struct serial_rs485 __user *rs485) > { > - if (copy_to_user(rs485, &port->rs485, sizeof(port->rs485))) > + unsigned long flags; > + int ret; > + > + spin_lock_irqsave(&port->lock, flags); > + ret = copy_to_user(rs485, &port->rs485, sizeof(port->rs485)); > + spin_unlock_irqrestore(&port->lock, flags); Looks good apart from this bit.. The copy needs to go to a temporary before the lock is taken otherwise we may sleep on a pagefault with irqs off Alan -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/