* [PATCH] nvme-fc: fix the fc_appid_store return value
@ 2022-08-06 8:32 Christoph Hellwig
2022-08-07 9:21 ` Chaitanya Kulkarni
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-08-06 8:32 UTC (permalink / raw)
To: linux-nvme; +Cc: Ewan D . Milne, James Smart, Muneendra Kumar M
"nvme-fc: fold t fc_update_appid into fc_appid_store" accidentally
changed the userspace interface for the appid attribute, because the code
that decrements "count" to remove a trailing '\n' in the parsing results
in the decremented value being incorrectly be returned from the sysfs
write. Fix this by keeping an orig_count variable for the full length
of the write.
Fixes: c814153c83a8 ("nvme-fc: fold t fc_update_appid into fc_appid_store")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Tested-by: Muneendra Kumar M <muneendra.kumar@broadcom.com>
---
drivers/nvme/host/fc.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 8d14df8eeab84..127abaf9ba5d6 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -3880,6 +3880,7 @@ static int fc_parse_cgrpid(const char *buf, u64 *id)
static ssize_t fc_appid_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
+ size_t orig_count = count;
u64 cgrp_id;
int appid_len = 0;
int cgrpid_len = 0;
@@ -3904,7 +3905,7 @@ static ssize_t fc_appid_store(struct device *dev,
ret = blkcg_set_fc_appid(app_id, cgrp_id, sizeof(app_id));
if (ret < 0)
return ret;
- return count;
+ return orig_count;
}
static DEVICE_ATTR(appid_store, 0200, NULL, fc_appid_store);
#endif /* CONFIG_BLK_CGROUP_FC_APPID */
--
2.30.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-fc: fix the fc_appid_store return value
2022-08-06 8:32 [PATCH] nvme-fc: fix the fc_appid_store return value Christoph Hellwig
@ 2022-08-07 9:21 ` Chaitanya Kulkarni
2022-08-07 9:23 ` Chaitanya Kulkarni
2022-08-28 12:11 ` Sagi Grimberg
2 siblings, 0 replies; 5+ messages in thread
From: Chaitanya Kulkarni @ 2022-08-07 9:21 UTC (permalink / raw)
To: Christoph Hellwig, linux-nvme
Cc: Ewan D . Milne, James Smart, Muneendra Kumar M
On 8/6/22 01:32, Christoph Hellwig wrote:
> "nvme-fc: fold t fc_update_appid into fc_appid_store" accidentally
> changed the userspace interface for the appid attribute, because the code
> that decrements "count" to remove a trailing '\n' in the parsing results
> in the decremented value being incorrectly be returned from the sysfs
> write. Fix this by keeping an orig_count variable for the full length
> of the write.
>
> Fixes: c814153c83a8 ("nvme-fc: fold t fc_update_appid into fc_appid_store")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Ewan D. Milne <emilne@redhat.com>
> Reviewed-by: James Smart <jsmart2021@gmail.com>
> Tested-by: Muneendra Kumar M <muneendra.kumar@broadcom.com>
> ---
Looks good.
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
-ck
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-fc: fix the fc_appid_store return value
2022-08-06 8:32 [PATCH] nvme-fc: fix the fc_appid_store return value Christoph Hellwig
2022-08-07 9:21 ` Chaitanya Kulkarni
@ 2022-08-07 9:23 ` Chaitanya Kulkarni
2022-08-10 14:23 ` Christoph Hellwig
2022-08-28 12:11 ` Sagi Grimberg
2 siblings, 1 reply; 5+ messages in thread
From: Chaitanya Kulkarni @ 2022-08-07 9:23 UTC (permalink / raw)
To: Christoph Hellwig, linux-nvme
Cc: Ewan D . Milne, James Smart, Muneendra Kumar M
On 8/6/22 01:32, Christoph Hellwig wrote:
> "nvme-fc: fold t fc_update_appid into fc_appid_store" accidentally
> changed the userspace interface for the appid attribute, because the code
> that decrements "count" to remove a trailing '\n' in the parsing results
> in the decremented value being incorrectly be returned from the sysfs
> write. Fix this by keeping an orig_count variable for the full length
> of the write.
>
>
while we are at it perhaps we should consider fixing following ?
diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c
index 8d14df8eeab8..7ba35b059214 100644
--- a/drivers/nvme/host/fc.c
+++ b/drivers/nvme/host/fc.c
@@ -3886,10 +3886,10 @@ static ssize_t fc_appid_store(struct device *dev,
char app_id[FC_APPID_LEN];
int ret = 0;
- if (buf[count-1] == '\n')
+ if (buf[count - 1] == '\n')
count--;
- if ((count > (16+1+FC_APPID_LEN)) || (!strchr(buf, ':')))
+ if ((count > (16 + 1 + FC_APPID_LEN)) || (!strchr(buf, ':')))
return -EINVAL;
cgrpid_len = fc_parse_cgrpid(buf, &cgrp_id);
@@ -3900,7 +3900,7 @@ static ssize_t fc_appid_store(struct device *dev,
return -EINVAL;
memset(app_id, 0x0, sizeof(app_id));
- memcpy(app_id, &buf[cgrpid_len+1], appid_len);
+ memcpy(app_id, &buf[cgrpid_len + 1], appid_len);
ret = blkcg_set_fc_appid(app_id, cgrp_id, sizeof(app_id));
if (ret < 0)
return ret;
or lmk if I should send a different patch..
-ck
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-fc: fix the fc_appid_store return value
2022-08-07 9:23 ` Chaitanya Kulkarni
@ 2022-08-10 14:23 ` Christoph Hellwig
0 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2022-08-10 14:23 UTC (permalink / raw)
To: Chaitanya Kulkarni
Cc: Christoph Hellwig, linux-nvme, Ewan D . Milne, James Smart,
Muneendra Kumar M
On Sun, Aug 07, 2022 at 09:23:27AM +0000, Chaitanya Kulkarni wrote:
> while we are at it perhaps we should consider fixing following ?
Yes, please send a separate patch. Please also remove the various
pointless braces in the hunk that you are touching.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] nvme-fc: fix the fc_appid_store return value
2022-08-06 8:32 [PATCH] nvme-fc: fix the fc_appid_store return value Christoph Hellwig
2022-08-07 9:21 ` Chaitanya Kulkarni
2022-08-07 9:23 ` Chaitanya Kulkarni
@ 2022-08-28 12:11 ` Sagi Grimberg
2 siblings, 0 replies; 5+ messages in thread
From: Sagi Grimberg @ 2022-08-28 12:11 UTC (permalink / raw)
To: Christoph Hellwig, linux-nvme
Cc: Ewan D . Milne, James Smart, Muneendra Kumar M
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-08-28 12:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-06 8:32 [PATCH] nvme-fc: fix the fc_appid_store return value Christoph Hellwig
2022-08-07 9:21 ` Chaitanya Kulkarni
2022-08-07 9:23 ` Chaitanya Kulkarni
2022-08-10 14:23 ` Christoph Hellwig
2022-08-28 12:11 ` Sagi Grimberg
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.