From: Keoseong Park Date: Fri, 26 Dec 2025 04:28:25 +0000 (+0900) Subject: scsi: ufs: core: Handle sentinel value for dHIDAvailableSize X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=695df7ea6099aadc11fac8d510e4b7c5839508e3;p=thirdparty%2Fkernel%2Flinux.git scsi: ufs: core: Handle sentinel value for dHIDAvailableSize 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 Reviewed-by: Peter Wang Reviewed-by: Bart Van Assche Link: https://patch.msgid.link/20251226042825epcms2p6f02ba12fa97ff4a69c00f6fb9ff55603@epcms2p6 Signed-off-by: Martin K. Petersen --- diff --git a/drivers/ufs/core/ufs-sysfs.c b/drivers/ufs/core/ufs-sysfs.c index b33f8656edb53..1017dd3ae5d3a 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); }