From patchwork Fri Jun 8 20:03:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Rostedt X-Patchwork-Id: 10455093 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 45E6D6037F for ; Fri, 8 Jun 2018 20:04:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3EE6428711 for ; Fri, 8 Jun 2018 20:04:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31BE2295F2; Fri, 8 Jun 2018 20:04:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C72A428711 for ; Fri, 8 Jun 2018 20:04:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lAflwodJ6a1XDqboXmAm5zf0ZLG+pERg5R6Z8fQDz7M=; b=AKAdsIncZ1YvLt Ufx8lnJhojrgpdGjavFy3svWdyaHsZyDYcwC655w0QQNdFo130Jq5M8/CnlYRPdSd/S5DARN2rupV g+c/xK+DZQ1rFdYxZaZe7EZJTQxUe2KJgP6GK+ncJw2xeaIZexh7uja9n1IVI2t2ddg89c68R89rn gnSySlattzMNXkTFsdSkW/WK54zUx6/CbX8xZmOns5bpYXopqB2yN62ja3bGhchlJOO615z8u05+I ytp12fnAdUCLD9uVlgPB0iJSYqwsJUQTRZdUD2cVDyZEhr7x1BqdBOrDyFVHsKVVLUyxoIf7EEbyH S4b8gQoHei1/iQQwcfbQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fRNcX-0007pU-Jt; Fri, 08 Jun 2018 20:04:25 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fRNcU-0007l6-9R for linux-arm-kernel@lists.infradead.org; Fri, 08 Jun 2018 20:04:24 +0000 Received: from vmware.local.home (unknown [217.76.163.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8819120874; Fri, 8 Jun 2018 20:04:02 +0000 (UTC) Date: Fri, 8 Jun 2018 16:03:55 -0400 From: Steven Rostedt To: Johan Hovold Subject: Re: [PATCH v5 2/4] kernel hacking: new config NO_AUTO_INLINE to disable compiler auto-inline optimizations Message-ID: <20180608160355.67712eb8@vmware.local.home> In-Reply-To: <20180607091816.GT13775@localhost> References: <1528186420-6615-3-git-send-email-changbin.du@intel.com> <201806060501.btF3aJMZ%fengguang.wu@intel.com> <20180606095714.1d3c2def@vmware.local.home> <20180606142600.GN13775@localhost> <20180606142622.2338abf6@vmware.local.home> <20180607041718.qpqucjzlvcm5h3gn@vireshk-i7> <20180607074628.kd3iyxevwj3ypzbr@intel.com> <20180607083856.ealw62v3wx43zeqz@vireshk-i7> <1303b1abf9f9229a8d3ccbb68a3e413266b360d7.camel@petrovitsch.priv.at> <20180607091025.m7dfix3e2xbwx4cs@vireshk-i7> <20180607091816.GT13775@localhost> X-Mailer: Claws Mail 3.15.1 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180608_130422_374102_AD0C289E X-CRM114-Status: GOOD ( 15.16 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , lgirdwood@gmail.com, yamada.masahiro@socionext.com, changbin.du@gmail.com, alex.elder@linaro.org, kbuild test robot , x86@kernel.org, linux@armlinux.org.uk, linux-sparse@vger.kernel.org, mingo@redhat.com, linux-arch@vger.kernel.org, arnd@arndb.de, linux-kbuild@vger.kernel.org, broonie@kernel.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, michal.lkml@markovi.net, gregkh@linuxfoundation.org, rdunlap@infradead.org, linux-kernel@vger.kernel.org, "Du, Changbin" , kbuild-all@01.org, Bernd Petrovitsch , akpm@linux-foundation.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Thu, 7 Jun 2018 11:18:16 +0200 Johan Hovold wrote: > If you want to work around the warning and think you can do it in some > non-contrived way, then go for it. > > Clearing the request buffer, checking for termination using strnlen, and > then using memcpy might not be too bad. > > But after all, it is a false positive, so leaving things as they stand > is fine too. Not sure how contrived you think this is, but it solves the warning without adding extra work in the normal case. -- Steve diff --git a/drivers/staging/greybus/fw-management.c b/drivers/staging/greybus/fw-management.c index 71aec14f8181..4fb9f1dff47d 100644 --- a/drivers/staging/greybus/fw-management.c +++ b/drivers/staging/greybus/fw-management.c @@ -150,15 +150,18 @@ static int fw_mgmt_load_and_validate_operation(struct fw_mgmt *fw_mgmt, } request.load_method = load_method; - strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE); + strncpy(request.firmware_tag, tag, GB_FIRMWARE_TAG_MAX_SIZE - 1); /* * The firmware-tag should be NULL terminated, otherwise throw error and * fail. */ - if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { - dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n"); - return -EINVAL; + if (request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 2] != '\0') { + if (tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] != '\0') { + dev_err(fw_mgmt->parent, "load-and-validate: firmware-tag is not NULL terminated\n"); + return -EINVAL; + } + request.firmware_tag[GB_FIRMWARE_TAG_MAX_SIZE - 1] = '\0'; } /* Allocate ids from 1 to 255 (u8-max), 0 is an invalid id */