Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752775AbbBWRib (ORCPT ); Mon, 23 Feb 2015 12:38:31 -0500 Received: from mailrelay103.isp.belgacom.be ([195.238.20.130]:5704 "EHLO mailrelay103.isp.belgacom.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbbBWRia (ORCPT ); Mon, 23 Feb 2015 12:38:30 -0500 X-Belgacom-Dynamic: yes X-Cloudmark-SP-Filtered: true X-Cloudmark-SP-Result: v=1.1 cv=ZT6Ny9SzQUL0U4sOn6xM6rLbT25dGdPOAe/imaXRw80= c=1 sm=2 a=JfrnYn6hAAAA:8 a=_fItlRjcpVnWKouLBG4A:9 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2CqDQBpZOtU/ykCtFtbgwaBLLA1BQEBAQEBAQUBd5dNgSREAQEBAQEBfIQ9LyOBGjeIMwHAapIyLIYHiXodhBUFmRWKbohFIoFFATwcgVE9MYJDAQEB From: Fabian Frederick To: linux-kernel@vger.kernel.org Cc: davem@davemloft.net, Peter Zijlstra , Fabian Frederick , Samuel Ortiz , netdev@vger.kernel.org Subject: [PATCH 1/1 net-next] irda: replace current->state by set_current_state() Date: Mon, 23 Feb 2015 18:38:24 +0100 Message-Id: <1424713105-12845-1-git-send-email-fabf@skynet.be> X-Mailer: git-send-email 2.1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1884 Lines: 57 Use helper functions to access current->state. Direct assignments are prone to races and therefore buggy. current->state = TASK_RUNNING can be replaced by __set_current_state() Thanks to Peter Zijlstra for the exact definition of the problem. Suggested-By: Peter Zijlstra Signed-off-by: Fabian Frederick --- net/irda/ircomm/ircomm_tty.c | 2 +- net/irda/irnet/irnet_ppp.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c index 40695b9..9940a41 100644 --- a/net/irda/ircomm/ircomm_tty.c +++ b/net/irda/ircomm/ircomm_tty.c @@ -811,7 +811,7 @@ static void ircomm_tty_wait_until_sent(struct tty_struct *tty, int timeout) break; } spin_unlock_irqrestore(&self->spinlock, flags); - current->state = TASK_RUNNING; + __set_current_state(TASK_RUNNING); } /* diff --git a/net/irda/irnet/irnet_ppp.c b/net/irda/irnet/irnet_ppp.c index 3c83a1e..1215693 100644 --- a/net/irda/irnet/irnet_ppp.c +++ b/net/irda/irnet/irnet_ppp.c @@ -305,7 +305,7 @@ irnet_ctrl_read(irnet_socket * ap, /* Put ourselves on the wait queue to be woken up */ add_wait_queue(&irnet_events.rwait, &wait); - current->state = TASK_INTERRUPTIBLE; + set_current_state(TASK_INTERRUPTIBLE); for(;;) { /* If there is unread events */ @@ -321,7 +321,7 @@ irnet_ctrl_read(irnet_socket * ap, /* Yield and wait to be woken up */ schedule(); } - current->state = TASK_RUNNING; + __set_current_state(TASK_RUNNING); remove_wait_queue(&irnet_events.rwait, &wait); /* Did we got it ? */ -- 2.1.0 -- 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/