Skip to contentSkip to conversation

iommu/vt-d: use kstrtoint_from_user() in dmar_perf_latency_write()

PATCH Applied Dmitry Antipov 2 participants 2 messages Jun 24 – Jul 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/vt-d: use kstrtoint_from_user() in dmar_perf_latency_write()

Simplify 'dmar_perf_latency_write()' by using the convenient 'kstrtoint_from_user()'.

---
 drivers/iommu/intel/debugfs.c | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
drivers/iommu/intel/debugfs.c +4 -12
index 21e4e465ca58..d87408ebb830 100644
@@ -690,19 +690,11 @@ static ssize_t dmar_perf_latency_write(struct file *filp,
 {
 	struct dmar_drhd_unit *drhd;
 	struct intel_iommu *iommu;
-	int counting;
-	char buf[64];
+	int ret, counting;
 
-	if (cnt > 63)
-		cnt = 63;
-
-	if (copy_from_user(&buf, ubuf, cnt))
-		return -EFAULT;
-
-	buf[cnt] = 0;
-
-	if (kstrtoint(buf, 0, &counting))
-		return -EINVAL;
+	ret = kstrtoint_from_user(ubuf, cnt, 0, &counting);
+	if (ret)
+		return ret;
 
 	switch (counting) {
 	case 0:
Signature · 1 line
2.54.0
maintainer Applied
#1 lore raw
Quoted 7 lines · Dmitry Antipov

Simplify 'dmar_perf_latency_write()' by using the convenient 'kstrtoint_from_user()'.

---
  drivers/iommu/intel/debugfs.c | 16 ++++------------
  1 file changed, 4 insertions(+), 12 deletions(-)

Queued for v7.3-rc1. Thanks a lot!