From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCH net-next 1/2] net: bridge: add support for raw sysfs port options Date: Sat, 21 Jul 2018 23:27:33 -0700 (PDT) Message-ID: <20180721.232733.468047452825591471.davem@davemloft.net> References: <20180720144826.29892-1-nikolay@cumulusnetworks.com> <20180720144826.29892-2-nikolay@cumulusnetworks.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, roopa@cumulusnetworks.com, bridge@lists.linux-foundation.org, wkok@cumulusnetworks.com, anuradhak@cumulusnetworks.com To: nikolay@cumulusnetworks.com Return-path: In-Reply-To: <20180720144826.29892-2-nikolay@cumulusnetworks.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: bridge-bounces@lists.linux-foundation.org Errors-To: bridge-bounces@lists.linux-foundation.org List-Id: netdev.vger.kernel.org From: Nikolay Aleksandrov Date: Fri, 20 Jul 2018 17:48:25 +0300 > + spin_lock_bh(&p->br->lock); > + ret = brport_attr->store_raw(p, (char *)buf); > + spin_unlock_bh(&p->br->lock); Please respect the const here. Have the methods do a kstrncup(); ... kfree(); sequence if they have to mangle the contents when there is a newline inside. I know the caller is passing in what was a non-const char pointer, I've looked at the implementation, but it might be that way forever. I looked at all other sysfs writes that need to do this \n --> \0 mangling and they either copy the string first into a static buffer or they do the kstrncup() thing. Thank you.