mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-04 04:06:26 +00:00
scsi: ufs: core: sysfs: Prevent div by zero
commiteb48e9fc00
upstream. Prevent a division by 0 when monitoring is not enabled. Fixes:1d8613a23f
("scsi: ufs: core: Introduce HBA performance monitor sysfs nodes") Cc: stable@vger.kernel.org Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20241120062522.917157-1-gwendal@chromium.org Reviewed-by: Can Guo <quic_cang@quicinc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c7a2f0ce45
commit
7b21233e5f
@ -452,6 +452,9 @@ static ssize_t read_req_latency_avg_show(struct device *dev,
|
||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||
struct ufs_hba_monitor *m = &hba->monitor;
|
||||
|
||||
if (!m->nr_req[READ])
|
||||
return sysfs_emit(buf, "0\n");
|
||||
|
||||
return sysfs_emit(buf, "%llu\n", div_u64(ktime_to_us(m->lat_sum[READ]),
|
||||
m->nr_req[READ]));
|
||||
}
|
||||
@ -519,6 +522,9 @@ static ssize_t write_req_latency_avg_show(struct device *dev,
|
||||
struct ufs_hba *hba = dev_get_drvdata(dev);
|
||||
struct ufs_hba_monitor *m = &hba->monitor;
|
||||
|
||||
if (!m->nr_req[WRITE])
|
||||
return sysfs_emit(buf, "0\n");
|
||||
|
||||
return sysfs_emit(buf, "%llu\n", div_u64(ktime_to_us(m->lat_sum[WRITE]),
|
||||
m->nr_req[WRITE]));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user