drivers/ufs/core/ufs-sysfs.c | 4 ++++ 1 file changed, 4 insertions(+)
JEDEC UFS spec defines 0xFFFFFFFF for dHIDAvailableSize as indicating no
valid fragmented size information. Returning the raw value can mislead
userspace. Return -ENODATA instead when the value is unavailable.
Signed-off-by: Keoseong Park <keosung.park@samsung.com>
---
drivers/ufs/core/ufs-sysfs.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c
index b33f8656edb5..1017dd3ae5d3 100644
--- a/drivers/ufs/core/ufs-sysfs.c
+++ b/drivers/ufs/core/ufs-sysfs.c
@@ -1847,6 +1847,7 @@ static ssize_t defrag_trigger_store(struct device *dev,
static DEVICE_ATTR_WO(defrag_trigger);
+#define UFS_HID_AVAILABLE_SIZE_INVALID 0xFFFFFFFFU
static ssize_t fragmented_size_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
@@ -1859,6 +1860,9 @@ static ssize_t fragmented_size_show(struct device *dev,
if (ret)
return ret;
+ if (value == UFS_HID_AVAILABLE_SIZE_INVALID)
+ return -ENODATA;
+
return sysfs_emit(buf, "%u\n", value);
}
--
2.25.1
On Fri, 26 Dec 2025 13:28:25 +0900, Keoseong Park wrote:
> JEDEC UFS spec defines 0xFFFFFFFF for dHIDAvailableSize as indicating no
> valid fragmented size information. Returning the raw value can mislead
> userspace. Return -ENODATA instead when the value is unavailable.
>
>
Applied to 6.20/scsi-queue, thanks!
[1/1] scsi: ufs: core: Handle sentinel value for dHIDAvailableSize
https://git.kernel.org/mkp/scsi/c/695df7ea6099
--
Martin K. Petersen
Keoseong, > JEDEC UFS spec defines 0xFFFFFFFF for dHIDAvailableSize as indicating no > valid fragmented size information. Returning the raw value can mislead > userspace. Return -ENODATA instead when the value is unavailable. Applied to 6.20/scsi-staging, thanks! -- Martin K. Petersen
On 12/25/25 9:28 PM, Keoseong Park wrote: > JEDEC UFS spec defines 0xFFFFFFFF for dHIDAvailableSize as indicating no > valid fragmented size information. Returning the raw value can mislead > userspace. Return -ENODATA instead when the value is unavailable. Reviewed-by: Bart Van Assche <bvanassche@acm.org>
On Fri, 2025-12-26 at 13:28 +0900, Keoseong Park wrote:
> JEDEC UFS spec defines 0xFFFFFFFF for dHIDAvailableSize as indicating
> no
> valid fragmented size information. Returning the raw value can
> mislead
> userspace. Return -ENODATA instead when the value is unavailable.
>
> Signed-off-by: Keoseong Park <keosung.park@samsung.com>
> ---
> drivers/ufs/core/ufs-sysfs.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-
> sysfs.c
> index b33f8656edb5..1017dd3ae5d3 100644
> --- a/drivers/ufs/core/ufs-sysfs.c
> +++ b/drivers/ufs/core/ufs-sysfs.c
> @@ -1847,6 +1847,7 @@ static ssize_t defrag_trigger_store(struct
> device *dev,
>
> static DEVICE_ATTR_WO(defrag_trigger);
>
> +#define UFS_HID_AVAILABLE_SIZE_INVALID 0xFFFFFFFFU
> static ssize_t fragmented_size_show(struct device *dev,
> struct device_attribute *attr, char *buf)
> {
> @@ -1859,6 +1860,9 @@ static ssize_t fragmented_size_show(struct
> device *dev,
> if (ret)
> return ret;
>
> + if (value == UFS_HID_AVAILABLE_SIZE_INVALID)
> + return -ENODATA;
> +
> return sysfs_emit(buf, "%u\n", value);
> }
Reviewed-by: Peter Wang <peter.wang@mediatek.com>
© 2016 - 2026 Red Hat, Inc.