Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nvme-fc: fix the fc_appid_store return value

"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: Chaitanya Kulkarni <kch@nvidia.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: James Smart <jsmart2021@gmail.com>
Tested-by: Muneendra Kumar M <muneendra.kumar@broadcom.com>

+2 -1
+2 -1
drivers/nvme/host/fc.c
··· 3880 3880 static ssize_t fc_appid_store(struct device *dev, 3881 3881 struct device_attribute *attr, const char *buf, size_t count) 3882 3882 { 3883 + size_t orig_count = count; 3883 3884 u64 cgrp_id; 3884 3885 int appid_len = 0; 3885 3886 int cgrpid_len = 0; ··· 3905 3904 ret = blkcg_set_fc_appid(app_id, cgrp_id, sizeof(app_id)); 3906 3905 if (ret < 0) 3907 3906 return ret; 3908 - return count; 3907 + return orig_count; 3909 3908 } 3910 3909 static DEVICE_ATTR(appid_store, 0200, NULL, fc_appid_store); 3911 3910 #endif /* CONFIG_BLK_CGROUP_FC_APPID */