From patchwork Thu Jan 23 17:28:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 212971 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4A9DAC2D0DB for ; Thu, 23 Jan 2020 17:30:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1483921734 for ; Thu, 23 Jan 2020 17:30:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ho+cihvv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728708AbgAWRaI (ORCPT ); Thu, 23 Jan 2020 12:30:08 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:44838 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727296AbgAWRaI (ORCPT ); Thu, 23 Jan 2020 12:30:08 -0500 Received: by mail-lf1-f66.google.com with SMTP id v201so2897786lfa.11; Thu, 23 Jan 2020 09:30:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=biNgWadq5TqNu1DhgNYk+76jxCQnnKZxQCgzQcvk4WE=; b=ho+cihvvm5qGd6cjf/bQfza0S/NPQnWeisIquDz2V5IYXaByfiEr1ppYLo1ABhYrKQ Dtk61QxO8gdmUKuN6MJ1LrK5WcRp1pRm/iLklK7H+NwzlUlU/QbQqZvIFaR8Wxrds9/A xatkgomlGvtSwJj+L0JBKoFG1CyQXdQw75N/SkdYw0CAjwPZzpHpAD9ELNNP4kZxl/I7 844zNpQidde5KD9VQaKM3UvJ7RbKxw1f0ootpKo8PYtnkALnraiH3aWrV+y3f7Nx7sh3 pwsU67k1CgOFiMNaTiAsPDoBx0GBKSGMQbU/jjwPQjwFPyHglrJnZUyx6RizfuKR3WO3 WoHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=biNgWadq5TqNu1DhgNYk+76jxCQnnKZxQCgzQcvk4WE=; b=YJ/HvN9Qj19fGHKFsHAYHKeX6bIDvoluJpWkVMgNyBjLVxh1O6jNkLuczcPOwgOt57 2vCI2ZGhOxGnVXziiwZdCQCCROftISfx915RrEVQD2wTa/KqohxbURin4kvOJEywWg0H kvmJ3qaZ+++GqQ/qTNP1AYP0W73o/LfpjPayMpapZW+8OkfrCr/gvMTeMgG9nASI5W5y 7WoJbVLAZz/tVmYUMgL/lER00eGgQO48f9MWVPzi4G/rgA+vCrddhOwIgfCT9Nnuojku W5vejLG+030NnMLnaqGTmnXqgeaOxGWdI8uhSvlaIcoX3WJhivvCVx0THxDNK5C2fdQr rsIA== X-Gm-Message-State: APjAAAXedRwK5WMT2Vm1qYNbmn/ei4NNiQUJ+gYXfuK94gTF921th2bW n9a/pL69HFhiN5Qpmgor5rA= X-Google-Smtp-Source: APXvYqyjvoR3stvPeCsW0baWBvB7O0BZozH/ovWybts0IXpKTrVH9LTL/4U8blSxm34xEpLH1MoepA== X-Received: by 2002:ac2:5f59:: with SMTP id 25mr5144118lfz.193.1579800605911; Thu, 23 Jan 2020 09:30:05 -0800 (PST) Received: from localhost.localdomain (79-139-233-37.dynamic.spd-mgts.ru. [79.139.233.37]) by smtp.gmail.com with ESMTPSA id l8sm1609332ljh.65.2020.01.23.09.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Jan 2020 09:30:05 -0800 (PST) From: Dmitry Osipenko To: MyungJoo Ham , Kyungmin Park , Chanwoo Choi Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1] PM / devfreq: Replace strncpy with strscpy Date: Thu, 23 Jan 2020 20:28:08 +0300 Message-Id: <20200123172808.5316-1-digetx@gmail.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org GCC produces this warning when kernel compiled using `make W=1`: warning: ‘strncpy’ specified bound 16 equals destination size [-Wstringop-truncation] 772 | strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); The strncpy doesn't take care of NULL-termination of the destination buffer, while the strscpy does. Signed-off-by: Dmitry Osipenko --- drivers/devfreq/devfreq.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index cceee8bc3c2f..f24d226f65c6 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -769,7 +769,7 @@ struct devfreq *devfreq_add_device(struct device *dev, devfreq->dev.release = devfreq_dev_release; INIT_LIST_HEAD(&devfreq->node); devfreq->profile = profile; - strncpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); + strscpy(devfreq->governor_name, governor_name, DEVFREQ_NAME_LEN); devfreq->previous_freq = profile->initial_freq; devfreq->last_status.current_frequency = profile->initial_freq; devfreq->data = data;