* [PATCH] dmaengine: idxd: remove trailing white space on input str for wq name
@ 2022-03-21 20:40 Dave Jiang
2022-04-11 13:52 ` Vinod Koul
0 siblings, 1 reply; 2+ messages in thread
From: Dave Jiang @ 2022-03-21 20:40 UTC (permalink / raw)
To: vkoul; +Cc: dmaengine
Add string processing with strim() in order to remove trailing white spaces
that may be input by user for the wq->name.
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
---
drivers/dma/idxd/sysfs.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/dma/idxd/sysfs.c b/drivers/dma/idxd/sysfs.c
index dbc7f9af11d3..08ceee801e4b 100644
--- a/drivers/dma/idxd/sysfs.c
+++ b/drivers/dma/idxd/sysfs.c
@@ -832,6 +832,7 @@ static ssize_t wq_name_store(struct device *dev,
size_t count)
{
struct idxd_wq *wq = confdev_to_wq(dev);
+ char *input, *pos;
if (wq->state != IDXD_WQ_DISABLED)
return -EPERM;
@@ -846,9 +847,14 @@ static ssize_t wq_name_store(struct device *dev,
if (wq->type == IDXD_WQT_KERNEL && device_pasid_enabled(wq->idxd))
return -EOPNOTSUPP;
+ input = kstrndup(buf, count, GFP_KERNEL);
+ if (!input)
+ return -ENOMEM;
+
+ pos = strim(input);
memset(wq->name, 0, WQ_NAME_SIZE + 1);
- strncpy(wq->name, buf, WQ_NAME_SIZE);
- strreplace(wq->name, '\n', '\0');
+ sprintf(wq->name, "%s", pos);
+ kfree(input);
return count;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dmaengine: idxd: remove trailing white space on input str for wq name
2022-03-21 20:40 [PATCH] dmaengine: idxd: remove trailing white space on input str for wq name Dave Jiang
@ 2022-04-11 13:52 ` Vinod Koul
0 siblings, 0 replies; 2+ messages in thread
From: Vinod Koul @ 2022-04-11 13:52 UTC (permalink / raw)
To: Dave Jiang; +Cc: dmaengine
On 21-03-22, 13:40, Dave Jiang wrote:
> Add string processing with strim() in order to remove trailing white spaces
> that may be input by user for the wq->name.
Applied, thanks
--
~Vinod
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-11 13:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-21 20:40 [PATCH] dmaengine: idxd: remove trailing white space on input str for wq name Dave Jiang
2022-04-11 13:52 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).