Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCDC32DE6F1 for ; Mon, 23 Mar 2026 13:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774271952; cv=none; b=sGhj+Omu4gkI1YciUmTKb4hC2iEwYm8eJIf4VSDmwDfHhAqBeamfgxfD3RdYqOOIYWPqqNwL1K0TO8KNOz8M6oVKLUNYb+LMm+hpQRu2KZMcvugYsI7qh/QxqumA+9/S7YP9X04VpLcNQBMaHs3Qdb2Im9cuxkmLhl1KPSd9jHw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774271952; c=relaxed/simple; bh=O2dHZFsOQ70hD1x0Z0vjR8SZREugcpDMh1YMqxxDscs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MOoq6oIA7wqZdd/9Ji9/jFWq+ypXiWDcGQmON7O9DVIcomIpyuqvr/wnghzqHj13lKlN0ZCSl2g+prw4V0quTgcJy7lxWm3UqYa+u9dVDZWNB2PyzOi9vO62UeSeDV39onKc780IZ6Qk41CMsuqiI3APRKd935hAFoxyEYNjVnk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dqCMTCxs; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dqCMTCxs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA179C4CEF7; Mon, 23 Mar 2026 13:19:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1774271952; bh=O2dHZFsOQ70hD1x0Z0vjR8SZREugcpDMh1YMqxxDscs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dqCMTCxswicc9Yza5YM4D0l654ciXMwEgNYxDyMI0yC2uaOnKrZUve1U5UwRhQVIb LfH/t9/4m7kv9o7GHtEJzjJhZdCpWR0OgOJexCEU+OVMYpes5S1uMbfENkHNBhud3+ x2y7d4Y8+GQXFLTNtH4vo+4pGenGhOmkapUFYiGr7+xoFPAtqtwrbBb1IIwlPl2Xux aXjs+vsAKPNFcA8+bvzvlwduwwTCq0467nQZEu+OLI+od+do3O+V16pelnoVRN1JX+ dvDo99PmNIkRJJg/fX49pypgPj04L8kaRmhUmGbEIU7wacukaZqtX7P457cXWtcRMM 8cpy+JyBa4nYA== From: Sasha Levin To: stable@vger.kernel.org Cc: Justin Stitt , Kees Cook , Wolfram Sang , Sasha Levin Subject: [PATCH 5.15.y 1/2] i2c: cp2615: replace deprecated strncpy with strscpy Date: Mon, 23 Mar 2026 09:19:09 -0400 Message-ID: <20260323131910.1715046-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2026032348-savor-throbbing-4586@gregkh> References: <2026032348-savor-throbbing-4586@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Justin Stitt [ Upstream commit e2def33f9ee1b1a8cda4ec5cde69840b5708f068 ] `strncpy` is deprecated for use on NUL-terminated destination strings [1]. We should prefer more robust and less ambiguous string interfaces. We expect name to be NUL-terminated based on its numerous uses with functions that expect NUL-terminated strings. For example in i2c-core-base.c +1533: | dev_dbg(&adap->dev, "adapter [%s] registered\n", adap->name); NUL-padding is not required as `adap` is already zero-alloacted with: | adap = devm_kzalloc(&usbif->dev, sizeof(struct i2c_adapter), GFP_KERNEL); With the above in mind, a suitable replacement is `strscpy` [2] due to the fact that it guarantees NUL-termination on the destination buffer without unnecessarily NUL-padding. 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 Signed-off-by: Justin Stitt Reviewed-by: Kees Cook Signed-off-by: Wolfram Sang Stable-dep-of: aa79f996eb41 ("i2c: cp2615: fix serial string NULL-deref at probe") Signed-off-by: Sasha Levin --- drivers/i2c/busses/i2c-cp2615.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/i2c/busses/i2c-cp2615.c b/drivers/i2c/busses/i2c-cp2615.c index 3ded28632e4c1..20f8f7c9a8cd4 100644 --- a/drivers/i2c/busses/i2c-cp2615.c +++ b/drivers/i2c/busses/i2c-cp2615.c @@ -298,7 +298,7 @@ cp2615_i2c_probe(struct usb_interface *usbif, const struct usb_device_id *id) if (!adap) return -ENOMEM; - strncpy(adap->name, usbdev->serial, sizeof(adap->name) - 1); + strscpy(adap->name, usbdev->serial, sizeof(adap->name)); adap->owner = THIS_MODULE; adap->dev.parent = &usbif->dev; adap->dev.of_node = usbif->dev.of_node; -- 2.51.0