Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1581943rdd; Thu, 11 Jan 2024 03:42:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgra2Js4GzN6QfcL0+7LUWp03nKH6UI4gti+GqLVOpdRB619WWlvkg2RQOuSIo37iAdBNU X-Received: by 2002:aa7:d754:0:b0:556:a29e:c3c2 with SMTP id a20-20020aa7d754000000b00556a29ec3c2mr605545eds.61.1704973352601; Thu, 11 Jan 2024 03:42:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704973352; cv=none; d=google.com; s=arc-20160816; b=dJUJIEHgIHxt05puPs8CfLuUbxvg7hFdiEitM41pWoIpgDbCdsuEeKNsqtuDuDN1Q7 JSdntHPke5m6LjsJi8ow8LfIUJDADk70F8/iYzMN/APcTs1Mqab3QuNqXEEGum+wKoix nEww/llb0RSlnZXtfxmGq945nh6E3WTjqAIjHvQEVK1/hvFiTykC8/mBkh8leSo7fmWd ODWLJVfg9cIfZ4KINQ6XN21zWDql3gggp9LBlHO0OUAjxV1P6BrovwA95YRZlZeOPtLJ TdQoBYdqRgYuOuKlLFHI7mO2yySxVQnd8ZlNeUAmVuSJR3aVDqFO2o2gzBK2+O0QdftM Pt+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=U34z3M5y8NqKnCvOeskNHlh3oGzO6JvIqhzswOkQUmk=; fh=5mQrMdfjpBR9Xd+GSnSPQVubDNae6daMhu9okflTqpA=; b=nJnbWryMKSe1G3HDJmP8lHdKrVLeZYpgflfh5BOIWUxMn85Nalt1VxYqAMRqeAJ2hH iO+YL6CMPfZ+Jehxj8RWjhEa5otSM321TFNR7tWeKCH/AcYOrRabi0qcJCV8BbdtSTGM 8GI8pt13njIOOm40NgbSTuaYyGetsnmnPGsxgWF4+y3PQN8AU2ADedmqgwqIwyqJv2x2 NOsLmx8SefeNMZWQGlEb1+yp+0gNLu0/Ds11+jOqOOvnmVZerwT2XXdl/iiiGICzmNpj VRiE53K0edWRsSDHFbuCE5PNG1+Xhc2Vo9+80NsDi2s66e4DTak9KUSJ4IHwcUe2mab1 rC7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="e/vn3dqn"; spf=pass (google.com: domain of linux-kernel+bounces-23505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23505-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c30-20020a50d65e000000b00551198f8d36si439618edj.428.2024.01.11.03.42.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 03:42:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="e/vn3dqn"; spf=pass (google.com: domain of linux-kernel+bounces-23505-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23505-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 587FA1F23BE6 for ; Thu, 11 Jan 2024 11:42:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 39B5215495; Thu, 11 Jan 2024 11:42:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="e/vn3dqn" Received: from mail-vk1-f172.google.com (mail-vk1-f172.google.com [209.85.221.172]) (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 01E198F62; Thu, 11 Jan 2024 11:42:21 +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-vk1-f172.google.com with SMTP id 71dfb90a1353d-4b77948f7deso1603258e0c.0; Thu, 11 Jan 2024 03:42:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704973341; x=1705578141; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=U34z3M5y8NqKnCvOeskNHlh3oGzO6JvIqhzswOkQUmk=; b=e/vn3dqn4K7/DqoMHPhU7mTETwTpDUQ3f3huhh4s6IfKR5XGSiXY//NUKYdwSGr5ia WVqU2eXqp5FEbsUgHXqfM8QfcHv3pilUOo+kq9r8OhZ8hrs8qdDTe3gJOf8jOjbTzFgJ yOrWJBwV7NfulignmnNohG/m5diu09O0ibwMr+9SNUBdTRDiP3rVyfMz63CsviFEOZtY XsusipAjrBro4HR7C9ZvbvU6SThANS4bIG6kui2aj+YK2dPzUImLbmLlGSNo1NL0Py9x 90AduWYKX8Kej3EouEqArhinAu6aBX00jBKCURd84V+Ln5IBNv6/mBPPP2e27GLFJ6N2 mv0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704973341; x=1705578141; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U34z3M5y8NqKnCvOeskNHlh3oGzO6JvIqhzswOkQUmk=; b=ojbtwqKYvx7tRkpgEr+MdpRgsq484O6krW30OIQy1Tn6c62s7v1XvwsiOd3Y4PecJr t6yI4PtIcv+AorK/DVdVscMS5fC+1/QHD/Umm0IdY1puyVpcMinYPZ0M3WryyqW77e5L PF4j2ksT2eCyOtEEbg6O+TAyft2odX919MfjpOk3+e1p2GDlT7Y+aZ1sNCHaY3+hfuzd TC4eX+WNR+pBpKYpww5XAwEA3SS7PcBhvDKGbGyuulUVnrjK3Sx+vOwIlBXwAGoQyRR0 iZ5QhpIZnxxFZIilR5TZ/kJHzsIddI6NCBt+IEL2Y2+WU0ZlNIaSMkY8ePjhoNw3jkaA zUnw== X-Gm-Message-State: AOJu0YwXuK33VbEFNchDiM5aprVkUnoBuDOILyZ2P89lNnx1o4BK2tB9 ogrQtIpPDzEAQbISGrEbjVJSv0x4Aqy4JmiwxW4= X-Received: by 2002:a05:6122:14af:b0:4b6:d1da:5bd1 with SMTP id c15-20020a05612214af00b004b6d1da5bd1mr242032vkq.2.1704973340720; Thu, 11 Jan 2024 03:42:20 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240110222210.193479-1-prabhakar.mahadev-lad.rj@bp.renesas.com> In-Reply-To: From: "Lad, Prabhakar" Date: Thu, 11 Jan 2024 11:41:54 +0000 Message-ID: Subject: Re: [PATCH] dmaengine: usb-dmac: Avoid format-overflow warning To: Geert Uytterhoeven Cc: Vinod Koul , =?UTF-8?Q?Uwe_Kleine=2DK=C3=B6nig?= , Tudor Ambarus , Kees Cook , dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Claudiu Beznea , Lad Prabhakar Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Geert, Thank you for the review. On Thu, Jan 11, 2024 at 9:05=E2=80=AFAM Geert Uytterhoeven wrote: > > Hi Prabhakar, > > On Wed, Jan 10, 2024 at 11:23=E2=80=AFPM Prabhakar wrote: > > From: Lad Prabhakar > > > > gcc points out that the fix-byte buffer might be too small: > > drivers/dma/sh/usb-dmac.c: In function 'usb_dmac_probe': > > drivers/dma/sh/usb-dmac.c:720:34: warning: '%u' directive writing betwe= en 1 and 10 bytes into a region of size 3 [-Wformat-overflow=3D] > > 720 | sprintf(pdev_irqname, "ch%u", index); > > | ^~ > > In function 'usb_dmac_chan_probe', > > inlined from 'usb_dmac_probe' at drivers/dma/sh/usb-dmac.c:814:9: > > drivers/dma/sh/usb-dmac.c:720:31: note: directive argument in the range= [0, 4294967294] > > 720 | sprintf(pdev_irqname, "ch%u", index); > > | ^~~~~~ > > drivers/dma/sh/usb-dmac.c:720:9: note: 'sprintf' output between 4 and 1= 3 bytes into a destination of size 5 > > 720 | sprintf(pdev_irqname, "ch%u", index); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > Maximum number of channels for USB-DMAC as per the driver is 1-99 so us= e > > u8 instead of unsigned int/int for DMAC channel indexing and make the > > pdev_irqname string long enough to avoid the warning. > > > > While at it use scnprintf() instead of sprintf() to make the code more > > robust. > > > > Signed-off-by: Lad Prabhakar > > Reviewed-by: Geert Uytterhoeven > > One nit below. > > > --- a/drivers/dma/sh/usb-dmac.c > > +++ b/drivers/dma/sh/usb-dmac.c > > > @@ -768,8 +768,8 @@ static int usb_dmac_probe(struct platform_device *p= dev) > > const enum dma_slave_buswidth widths =3D USB_DMAC_SLAVE_BUSWIDT= H; > > struct dma_device *engine; > > struct usb_dmac *dmac; > > - unsigned int i; > > int ret; > > + u8 i; > > Personally, I'm not much a fan of making loop counters smaller than > (unsigned) int. If you do go this way, there are more loops over all > channels still using int. > Agreed. So shall I drop Kees suggestion and leave the patch as is? Cheers, Prabhakar