From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932569AbbDKMVP (ORCPT ); Sat, 11 Apr 2015 08:21:15 -0400 Received: from mail-wi0-f176.google.com ([209.85.212.176]:35480 "EHLO mail-wi0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751519AbbDKMVN (ORCPT ); Sat, 11 Apr 2015 08:21:13 -0400 Date: Sat, 11 Apr 2015 15:20:43 +0300 (EEST) From: =?ISO-8859-2?Q?Giedrius_Statkevi=E8ius?= X-X-Sender: giedrius@localhost.localdomain To: Sudip Mukherjee cc: =?ISO-8859-2?Q?Giedrius_Statkevi=E8ius?= , lidza.louina@gmail.com, markh@compro.net, gregkh@linuxfoundation.org, driverdev-devel@linuxdriverproject.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 1/2 RESEND] staging: dgnc: remove dead code in dgnc_tty_write() In-Reply-To: <20150411045144.GA3496@sudip-PC> Message-ID: References: <1428677335-6853-1-git-send-email-giedrius.statkevicius@gmail.com> <20150411045144.GA3496@sudip-PC> User-Agent: Alpine 2.03 (LNX 1266 2009-07-14) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323328-866545806-1428754848=:3702" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323328-866545806-1428754848=:3702 Content-Type: TEXT/PLAIN; charset=utf-8 Content-Transfer-Encoding: 8BIT On Sat, 11 Apr 2015, Sudip Mukherjee wrote: > On Fri, Apr 10, 2015 at 05:48:54PM +0300, Giedrius Statkevičius wrote: > > Remove the dead code protected by in_user in dgnc_tty_write() because it is set > > to 0 and never changed to 1 thus the code in ifs never gets executed. > dgnc_tty_write() is being called by dgnc_tty_put_char() and it is also > the write callback function of struct tty_operations, so I think the > correct fix will be to use from_user and make it 0 when > dgnc_tty_put_char() calls this function else make it 1 to inform the > function that the data wil be coming from the userspace. Maybe some > thing like this: Well, I think this is wrong because: * parameter of write member of struct tty_operations buf is not tagged with "__user" so it should be safe to just memcpy() from it * Looked through some other write operations in other tty drivers and I've never seen copy_from_user() used on buf argument of write operation - always memcpy() or some other similar function * Ldd3 (and the comments in tty_driver.h) says that write could be called from interrupt context too so it can't sleep and thus use copy_from_user() While looking through I've caught that dgnc_TmpWriteBuf could be also deleted because it will be unused if this patch goes through. If it does then I'll send another one (or should I send a v3?) Su pagarba / Regards, Giedrius --8323328-866545806-1428754848=:3702--