From: Dave Jiang <dave.jiang@intel.com>
To: "Alexander A. Klimov" <grandmaster@al2klimov.de>,
"Vinod Koul" <vkoul@kernel.org>, "Frank Li" <Frank.Li@kernel.org>,
"Thomas Weißschuh" <linux@weissschuh.net>,
"Ujjal Singh" <ujjal.singh@intel.com>,
"open list:DMA GENERIC OFFLOAD ENGINE SUBSYSTEM"
<dmaengine@vger.kernel.org>,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] dmaengine: ioatdma: use !kstrtoint(), not sscanf()!=-1
Date: Thu, 28 May 2026 13:06:25 -0700 [thread overview]
Message-ID: <da523982-576f-4bf8-95b6-79cecf683f55@intel.com> (raw)
In-Reply-To: <48fac400-4813-4b14-986d-8392c7faf936@al2klimov.de>
On 5/26/26 11:06 AM, Alexander A. Klimov wrote:
>
>
> On 5/26/26 16:49, Dave Jiang wrote:
>>
>>
>> On 5/25/26 11:13 PM, Alexander A. Klimov wrote:
>>> Depending on the user input, sscanf() may return 0 for 0 success.
>>> But intr_coalesce_store() wants sscanf() to parse one number,
>>> so expect 1 from sscanf(), not any int except -1.
>>>
>>> While on it, fix typo in %du by using just %d,
>>> as this interface expects %d or %d\n.
>>> Latter made scripts/checkpatch.pl complain,
>>> so use kstrtoint() instead of sscanf().
>>>
>>> Fixes: 268e2519f5b7 ("dmaengine: ioatdma: Add intr_coalesce sysfs entry")
>>> Signed-off-by: Alexander A. Klimov <grandmaster@al2klimov.de>
>>> ---
>>> drivers/dma/ioat/sysfs.c | 2 +-
>>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/dma/ioat/sysfs.c b/drivers/dma/ioat/sysfs.c
>>> index e796ddb5383f..f59df569956a 100644
>>> --- a/drivers/dma/ioat/sysfs.c
>>> +++ b/drivers/dma/ioat/sysfs.c
>>> @@ -144,7 +144,7 @@ size_t count)
>>> int intr_coalesce = 0;
>>> struct ioatdma_chan *ioat_chan = to_ioat_chan(c);
>>> - if (sscanf(page, "%du", &intr_coalesce) != -1) {
>>> + if (!kstrtoint(page, 10, &intr_coalesce)) {
>>
>> looks good. We can probably use kstrtouint() since we are expecting a positive number always.
>
> This would break `return -EINVAL;` below
Shouldn't we just drop the < 0 compare since it's no longer needed?
>
>>
>> DJ
>>
>>> if ((intr_coalesce < 0) ||
>>> (intr_coalesce > IOAT_INTRDELAY_MASK))
>>> return -EINVAL;
>>
>
next prev parent reply other threads:[~2026-05-28 20:06 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260526061321.6123-1-grandmaster@al2klimov.de>
2026-05-26 6:13 ` [PATCH] dmaengine: ioatdma: use !kstrtoint(), not sscanf()!=-1 Alexander A. Klimov
2026-05-26 6:24 ` sashiko-bot
2026-05-26 14:49 ` Dave Jiang
2026-05-26 18:06 ` Alexander A. Klimov
2026-05-28 20:06 ` Dave Jiang [this message]
[not found] ` <ef38b0e8-2b6f-4f65-bac5-177b981479ae@al2klimov.de>
2026-06-01 15:12 ` Dave Jiang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da523982-576f-4bf8-95b6-79cecf683f55@intel.com \
--to=dave.jiang@intel.com \
--cc=Frank.Li@kernel.org \
--cc=dmaengine@vger.kernel.org \
--cc=grandmaster@al2klimov.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@weissschuh.net \
--cc=ujjal.singh@intel.com \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox