Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp415152rdb; Mon, 18 Sep 2023 21:42:45 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFn9rBvnf5JcNiFV5SyqWCW5iAQ1N5Y+1CuWQPBdpr4s5gdf0nsyzrLnA9Z/o9Mb//5z5PD X-Received: by 2002:a05:6a00:23c4:b0:68f:cd71:45d5 with SMTP id g4-20020a056a0023c400b0068fcd7145d5mr14147500pfc.3.1695098564898; Mon, 18 Sep 2023 21:42:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695098564; cv=none; d=google.com; s=arc-20160816; b=aEUxVOumyf7LGxF0YZON28j34GrxFOau8IGG9tK4I0gwMu+x6N4gBCENvB5s8f4W4e 2Z3JvuagVmh7pQL1pvFuKMma2yjQc7uhzKeXnhqFl9LoHFwqdIhX0WvM7WKyoJmp80KD 2lUXuuFfDxaTYnoiDWRTOUU66XEzOkne07UU5fp59fYhUkmPRkO+bFW1BfpEdj4yHnxr bqF13QL5Zooo0H9tIIavl0T9RdEWbNAZnS59XUF2BRY5c4LbSC/UpuVSQQjQI8ds8tPU D2cA5ll5twkckMHGGSxLdwfyJJJ1BQ9YOg/12VJr/VFl0Kjed9jCtcXZIKXyGLGi5ibi kuyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=of1G2AjFUxK4T2lKuwOZsNYvvlYd/OC9AdRH6bOHIA4=; fh=qqQ/IAZllMaOXytDFYIOFdbQB5+Fl2HUra2PKBqf0p0=; b=q3A2qYpY2p80pRVGqGi2Y1n/5jCkWqa4c6uujDvbD/ip3NhRbEa/+0WvlRtzXMTh8t gfraivTYovBbVSaa88nFXxaeazNQpA34hP+RgVuRrnQsHqDUHMAYwFPKOOTOl+NICC/M jaFJM+2R72goPtIVCe6Q7NLboFz49z13QwdFw08Hr7Qyv5nTsjGsKRPbx1q4xcs1SY9W USErCczLnTb9alOSn9bDRSuj33t+wRq7zhADMpFh49Fbns5KyzytWaQcgz8/UZbrprP7 ncJfwFupTO9JJg4xgZ+GHNJHUJk+97KP4Cb+m0aO4tN4dxw7lKCcJf7WRhKOyMHt9cQO v7Jw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kcJjzbMC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id u62-20020a638541000000b00578bdc2ccadsi135016pgd.197.2023.09.18.21.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Sep 2023 21:42:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kcJjzbMC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 72EBF806138E; Mon, 18 Sep 2023 21:41:33 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229645AbjISEl1 (ORCPT + 99 others); Tue, 19 Sep 2023 00:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229534AbjISElZ (ORCPT ); Tue, 19 Sep 2023 00:41:25 -0400 Received: from mail-oi1-x24a.google.com (mail-oi1-x24a.google.com [IPv6:2607:f8b0:4864:20::24a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2D3310E for ; Mon, 18 Sep 2023 21:41:18 -0700 (PDT) Received: by mail-oi1-x24a.google.com with SMTP id 5614622812f47-3aa1396ffa6so6725416b6e.0 for ; Mon, 18 Sep 2023 21:41:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1695098478; x=1695703278; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=of1G2AjFUxK4T2lKuwOZsNYvvlYd/OC9AdRH6bOHIA4=; b=kcJjzbMCd39hA1de/mqscnEh3qvoZLW10D59Wm12N9CbtY002l6eXtp6T+yGXEcmZB 1njIp3cQpvk+Wsvenx99PbG1nIU0iaqh9ACYrh2bTINF8yahpQZ9XNsprvJ8h26Vj4O4 1TFG6qhtYBYQ6mGaqECaJVP+BrHKqUSwqbeXtToHmsxYxPzqFeRrxtYHcBpaWwFHQ7Wy SeZIbQxl6Kagv79bTw1wLzpZ0iKlL9o+6JRa2L0QnTFmOcngvuubz0GOqhvs+saCZfIF H5PQoM+USm2z7F4Xkz5wczpggTALGrs7XIZg277KgFXELUH5s5waUund3H9HqTkZHbE/ prZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695098478; x=1695703278; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=of1G2AjFUxK4T2lKuwOZsNYvvlYd/OC9AdRH6bOHIA4=; b=dgs0iX9Na6t4+Y7X53JykBHx/0M8ZSt/IEq+bEerS/H1bokTznLi/lV48wkIrw/GN5 FZFgHNnIuBtjuSiu/B1d/yv29AZrwBGdb1yMA1gWT/8RDHs6boFqI3KxX43hRWSNbpd2 BN1PoOV7L3xbAeUabk7lFKxo4sSzyvui95jqa5DBnJwEVy+81Hj0Ig1ufnmeA4yygZ1X LTz3SO3IGI7zK/QFZHpowDPtXvpjC8YhhoLPN9Bf90vm1W8F79COhtY/8sOXXDOA9+tn XGCVTHKRooluCcx3WI3ay55wQM86I9XF8Mo35Sc8JNVHX9WYduXzdHh8rXwH6R7H+a+H 6taw== X-Gm-Message-State: AOJu0YygWHHHJsRgrjyWS36cekeGRvyKrrj8IPj2u5+zPed4EXkHZNjl jnHCaHpRJCIRGy344cxxjtQlWu4YOaEFhgfmJg== X-Received: from jstitt-linux1.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:23b5]) (user=justinstitt job=sendgmr) by 2002:a05:6808:199a:b0:3ad:29a4:f542 with SMTP id bj26-20020a056808199a00b003ad29a4f542mr756370oib.5.1695098478040; Mon, 18 Sep 2023 21:41:18 -0700 (PDT) Date: Tue, 19 Sep 2023 04:41:16 +0000 Mime-Version: 1.0 X-B4-Tracking: v=1; b=H4sIAGsmCWUC/53NTQ6CMBCG4auYrh3TFsGflfcwhNR2KBOBkik2G sLdrRzB3byz+J5FRGTCKK67RTAmihTGHHq/E7Yzo0cgl1toqQt5UUdwTAk5gp9e+R7AD6aUEoJ 5zmyob/rkYkPaggVTFrZy54erdCvy4MTY0nvD7nXujuIc+LPZSf2+fzFJgQKZMSNPlUUtbz4E3 +PBhkHU67p+AdX0M2DlAAAA X-Developer-Key: i=justinstitt@google.com; a=ed25519; pk=tC3hNkJQTpNX/gLKxTNQKDmiQl6QjBNCGKJINqAdJsE= X-Developer-Signature: v=1; a=ed25519-sha256; t=1695098477; l=1887; i=justinstitt@google.com; s=20230717; h=from:subject:message-id; bh=mJhdmvY4dhQaVYSKiTNMqir+icefxTZRFVt1lST3CX4=; b=tMzBU+KLFc2Eppj6xXIygZ2Dq/nC2zJMApa9X+WMt7T4LpaJjlfb6RpBbKzgk5C4yKzfWUYPB NhfiYY2Kel9D80fFCLgHDN2zBJ88PddQysZHhrrgQAoCI2mJ91yQ9I6 X-Mailer: b4 0.12.3 Message-ID: <20230919-drivers-gpu-drm-gma500-oaktrail_lvds_i2c-c-v2-1-9ebe6983b4cb@google.com> Subject: [PATCH v2] drm/gma500: refactor deprecated strncpy From: Justin Stitt To: Patrik Jakobsson , David Airlie , Daniel Vetter Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Justin Stitt Content-Type: text/plain; charset="utf-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Mon, 18 Sep 2023 21:41:33 -0700 (PDT) `strncpy` is deprecated for use on NUL-terminated destination strings [1]. We should prefer more robust and less ambiguous string interfaces. Since `chan->base.name` is expected to be NUL-terminated, a suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on the destination buffer without also unnecessarily NUL-padding (since `chan` is kzalloc'd already). Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - use sizeof() instead of I2C_NAME_SIZE (thanks Kees, Patrik) - Link to v1: https://lore.kernel.org/r/20230914-drivers-gpu-drm-gma500-oaktrail_lvds_i2c-c-v1-1-0a53a076ce20@google.com --- drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c b/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c index 06b5b2d70d48..939c53fd09e8 100644 --- a/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c +++ b/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c @@ -141,7 +141,7 @@ struct gma_i2c_chan *oaktrail_lvds_i2c_init(struct drm_device *dev) chan->drm_dev = dev; chan->reg = dev_priv->lpc_gpio_base; - strncpy(chan->base.name, "gma500 LPC", I2C_NAME_SIZE - 1); + strscpy(chan->base.name, "gma500 LPC", sizeof(chan->base.name)); chan->base.owner = THIS_MODULE; chan->base.algo_data = &chan->algo; chan->base.dev.parent = dev->dev; --- base-commit: 3669558bdf354cd352be955ef2764cde6a9bf5ec change-id: 20230914-drivers-gpu-drm-gma500-oaktrail_lvds_i2c-c-a53c6d8bd62f Best regards, -- Justin Stitt