Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1274719rdd; Wed, 10 Jan 2024 14:28:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGFk269Juhg2boY62GWZV4SNyDvr+9o3b/xYICp6WccEM+5u6b6aNmBSUGVeUEXIt7VfMHK X-Received: by 2002:ac8:7f09:0:b0:429:bb88:6fb0 with SMTP id f9-20020ac87f09000000b00429bb886fb0mr219159qtk.13.1704925684819; Wed, 10 Jan 2024 14:28:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704925684; cv=none; d=google.com; s=arc-20160816; b=qEXdGiaIBxLBbOEuRrzzKQ47SRFQAa/ykGG2T0iIXgU+9GHU4QKzRQf2iZsnEJyb8Z nDk+UALUE0RUYBWagTiFVVDxg6MlZys1Qg8oXlt0RmykxM3VCYOKK/t70nYVMHX3EFRd MWKlP323zM/gdW8G3sePoBlxlNuskyG8UFQPw9awk2ybpujaheJE0EJZthcxkWH0j+YW yTAvSDvrL+Qmc7NtpxF7CiPo1EKEyoPAGuipOfSfqTAzCO0rS8fIWijPgZBtpDUH9ZhE r9brDk4cSn6cx+qCZERvMhzVcS5xbtiYZHFvRkIcyEBwN9PcQnQT2MZA4QGEls2hzGZz Udbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=tV1DZHUcUVZrnewacKcGxbUMRr8vxmCiDHV3WTeMLmU=; fh=Ddni32KzbBYCDgRlOTzkb36a1ySQZssaGIYPspol7ck=; b=WY0sQ8Za2p0R/v4rksnj4T/FcvNk1IJ+9o6blk28OuNUDm67ywL1MqGpYt6tUUe5Id L9/OM+vqimNwqeukvNuPHIf9rERJ05wpV78UkrPa4G058JVVYZ2Fd7DeXjteHPXwh1NK 1A9aAYkhp9tpRy5OHGjr/Hosp7FwyUuMyfvqLyc/q/wQhiLhQGiy7ORR+8F0W7WIbTsu /JoXG71cKItSnyzlQqBKJthB8ofF+SNqqaVTbZqBpRQelROOAMABOxTjozBAgEZNDQLM xQGo6r1D3ugLcdSJTTFrb8tR2By2wpM3vTRWexlEZ/NUWQFmG28opIgU0h5lfgZfxDzz 8oIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JUZ8P90n; spf=pass (google.com: domain of linux-kernel+bounces-22849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22849-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id v21-20020a05622a145500b00429a3d1df83si4640028qtx.260.2024.01.10.14.28.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:28:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=JUZ8P90n; spf=pass (google.com: domain of linux-kernel+bounces-22849-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22849-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 934C31C2252D for ; Wed, 10 Jan 2024 22:28:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 394CA4F89C; Wed, 10 Jan 2024 22:27:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="JUZ8P90n" Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E23DD4F88A; Wed, 10 Jan 2024 22:27:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-40e5508ecb9so19726675e9.3; Wed, 10 Jan 2024 14:27:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704925674; x=1705530474; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=tV1DZHUcUVZrnewacKcGxbUMRr8vxmCiDHV3WTeMLmU=; b=JUZ8P90nhLvv0mWmCaSxWsarNRaY1hnkNe+3cYZbxR//2iLCRgggX0zRk+UuKlPtlb oYsPg/y6/Zqb4BUAUxmyXnw8lgXYuVjdinDdC78AEdksOPIpcBMCK5A/9w5403dIJHVB nxyACGNvMwWdiQfkOlN3HJ39ayXvvcjP7vkq79GeHO/K77mg3eEZ2eUPjS9fBMFg27V9 SCUFVmudHTPI7wV8Esp6kCndJFiDrMvktcceW1+nyE8xqItRq/vQMhTExQ5wrvb/O4KG dKlr+SVnTb0K2oWRbdbiYSuVeRcBqFKyK+VrkJsaZxPy/5guaN5aT7E9l28Hy1ThITGG nlxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704925674; x=1705530474; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=tV1DZHUcUVZrnewacKcGxbUMRr8vxmCiDHV3WTeMLmU=; b=NDBoCFZK+dbkARp5cg6L0PmWzMGnSJEYxDwDlIujS9fpFruEUP2GcS76uY8kcLHaQG a1EDAxONde+KAMP2K28nUYk1MdxuYN0dleS7xn1T605x1lBIfoEQae4Wpd9vn3aQkuJa y1nyxaWb1pR1JiH3Gc4NXnECiISkQj+Infk8tcV78KcYYSqvHzZwglhNEjrjT9eKmiBf t72doZbvEUue9Q30VcCICgIVJoCOl/kJ+sWVw21ih/QJTBLbfhBsaWvI1XSR9qmHFCFu E0ddpMbQYwmTTAAtRdNSe8tqs/NWyDe3ieHyhAPwk2kv/qca/LZZ7PpbhJ3SUK8wth7u XScQ== X-Gm-Message-State: AOJu0YyLxiRx/QfbvZZnY650jkPvOgPEBLij2OdOePEKrPhoC3ABUuoS 7oLKeI5A8o1Q0yiUCRpUAUw= X-Received: by 2002:a05:600c:2d15:b0:40e:4a88:2de2 with SMTP id x21-20020a05600c2d1500b0040e4a882de2mr54041wmf.155.1704925673813; Wed, 10 Jan 2024 14:27:53 -0800 (PST) Received: from prasmi.home ([2a00:23c8:2500:a01:3989:437:3f03:172f]) by smtp.gmail.com with ESMTPSA id l37-20020a05600c1d2500b0040e4ca7fcb4sm3637953wms.37.2024.01.10.14.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 14:27:53 -0800 (PST) From: Prabhakar X-Google-Original-From: Prabhakar To: Vinod Koul , Geert Uytterhoeven Cc: Biju Das , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Prabhakar , Claudiu Beznea , Lad Prabhakar Subject: [PATCH] dmaengine: sh: rz-dmac: Avoid format-overflow warning Date: Wed, 10 Jan 2024 22:27:17 +0000 Message-Id: <20240110222717.193719-1-prabhakar.mahadev-lad.rj@bp.renesas.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Lad Prabhakar The max channel count for RZ DMAC is 16, hence use u8 instead of unsigned int and make the pdev_irqname string long enough to avoid the warning. This fixes the below issue: drivers/dma/sh/rz-dmac.c: In function ‘rz_dmac_probe’: drivers/dma/sh/rz-dmac.c:770:34: warning: ‘%u’ directive writing between 1 and 10 bytes into a region of size 3 [-Wformat-overflow=] 770 | sprintf(pdev_irqname, "ch%u", index); | ^~ In function ‘rz_dmac_chan_probe’, inlined from ‘rz_dmac_probe’ at drivers/dma/sh/rz-dmac.c:910:9: drivers/dma/sh/rz-dmac.c:770:31: note: directive argument in the range [0, 4294967294] 770 | sprintf(pdev_irqname, "ch%u", index); | ^~~~~~ drivers/dma/sh/rz-dmac.c:770:9: note: ‘sprintf’ output between 4 and 13 bytes into a destination of size 5 770 | sprintf(pdev_irqname, "ch%u", index); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ While at it use scnprintf() instead of sprintf() to make the code more robust. Signed-off-by: Lad Prabhakar --- drivers/dma/sh/rz-dmac.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c index fea5bda34bc2..1f1e86ba5c66 100644 --- a/drivers/dma/sh/rz-dmac.c +++ b/drivers/dma/sh/rz-dmac.c @@ -755,11 +755,11 @@ static struct dma_chan *rz_dmac_of_xlate(struct of_phandle_args *dma_spec, static int rz_dmac_chan_probe(struct rz_dmac *dmac, struct rz_dmac_chan *channel, - unsigned int index) + u8 index) { struct platform_device *pdev = to_platform_device(dmac->dev); struct rz_lmdesc *lmdesc; - char pdev_irqname[5]; + char pdev_irqname[6]; char *irqname; int ret; @@ -767,7 +767,7 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac, channel->mid_rid = -EINVAL; /* Request the channel interrupt. */ - sprintf(pdev_irqname, "ch%u", index); + scnprintf(pdev_irqname, sizeof(pdev_irqname), "ch%u", index); channel->irq = platform_get_irq_byname(pdev, pdev_irqname); if (channel->irq < 0) return channel->irq; @@ -845,9 +845,9 @@ static int rz_dmac_probe(struct platform_device *pdev) struct dma_device *engine; struct rz_dmac *dmac; int channel_num; - unsigned int i; int ret; int irq; + u8 i; dmac = devm_kzalloc(&pdev->dev, sizeof(*dmac), GFP_KERNEL); if (!dmac) -- 2.34.1