Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1274435imm; Fri, 8 Jun 2018 13:04:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIsMzV8YQqAsKlgc0r+erdqKtQjsh/w+6H5XGdHjTCS/hTbwOYXm4j4Wlk2IXqkyXKK2Cad X-Received: by 2002:a62:86c3:: with SMTP id x186-v6mr7418017pfd.4.1528488290424; Fri, 08 Jun 2018 13:04:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528488290; cv=none; d=google.com; s=arc-20160816; b=rEMFeUclQsQ9gC8zuVnca6gY+CiZNWmh2hsgjX4RBMFm4verU/ECiOKI5J4q5LKlXd Z77ekXCcK77FvzydAg3HDZIfiANM4UjU9womHTj6UmJuTpFMHlnmZBrvUFG2GE0AnrB3 mAnv/rqTYSShTVLikT3OQrgiC1b0K/msP+eaFbAo8lxrzuliwxXNwbzd5EsGFevQyCfT LhtUqII2TF4KkL55ulWp5Mixk5rJg7K7VrOGYSV/19B62F7mDd7m/awsqxX3M8kgzbzs CKO8Eg+3CefCJnas1aVNXinv3ZcZN/ImIlziKVDbcgBN3l6MVQ+VEUnWAulQlzZjKJuO rB4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=oNzV1zCHkyT8xKXGnVrxQMPMCf3Q8RjjiPRB8FxEVjs=; b=EummCTww42cD1+owrvWDOGGpoRS4Sa6dsoyiclivpXWs6g4YvLa8PkKXkqmfXJmqnw noYu8tDseCO4Ye7QFqHpBwVy67GsjW/cAodhPTfN4VuNoyJB7DJ+jxZbeVr8JiM+3m7h zlNodS7ZzXQpJ8FQWiSBbu0ONz3Z/C6v+uKh3ELOwkcv9h8XOX13vmL5OeUTAXlhJaQg /qMOJxPOAixgU4Yi+vuNEhHCnm2vxZsf7xuA+usba3L1F+eC1VlGN6jflwROdCVZRdvJ hTHEsXIA0wKHEboKtagiyglBs5OHrzfx+k9J2bsLKHI8izmCQYr8lRrBJEbKyTH95o0M n6hg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ay5-v6si55575814plb.459.2018.06.08.13.04.35; Fri, 08 Jun 2018 13:04:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752739AbeFHUEN (ORCPT + 99 others); Fri, 8 Jun 2018 16:04:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:48426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752478AbeFHUEL (ORCPT ); Fri, 8 Jun 2018 16:04:11 -0400 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 Cc: Viresh Kumar , Bernd Petrovitsch , "Du, Changbin" , gregkh@linuxfoundation.org, alex.elder@linaro.org, kbuild test robot , linux-arch@vger.kernel.org, michal.lkml@markovi.net, linux-kernel@vger.kernel.org, arnd@arndb.de, yamada.masahiro@socionext.com, lgirdwood@gmail.com, broonie@kernel.org, rdunlap@infradead.org, x86@kernel.org, linux@armlinux.org.uk, linux-sparse@vger.kernel.org, mingo@redhat.com, kbuild-all@01.org, akpm@linux-foundation.org, changbin.du@gmail.com, tglx@linutronix.de, linux-kbuild@vger.kernel.org, linux-arm-kernel@lists.infradead.org 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 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */