On Thu, Apr 17, 2025 at 03:00:15PM -0700, Zaid Alali wrote: > +static ssize_t error_type_set(struct file *file, const char __user *buf, > + size_t count, loff_t *ppos) > { > int rc; > + u64 val; > + > + memset(einj_buf, 0, sizeof(einj_buf)); > + if (copy_from_user(einj_buf, buf, count)) > + return -EFAULT; > + > + if (strncmp(einj_buf, "V2_", 3) == 0) { It's twice as common in Linux kernel code to see string equality checked with: if (!strncmp(einj_buf, "V2_", 3)) > + if (!sscanf(einj_buf, "V2_%llx", &val)) More comprehensive error checking with this: ret = kstrtoull(einj_buf + 3, 16, &val); if (!ret) return -EINVAL; > + return -EINVAL; > + } else { > + if (!sscanf(einj_buf, "%llx", &val)) Ditto kstrtoull() use. > + return -EINVAL; > + } > > rc = einj_validate_error_type(val); > if (rc) > @@ -722,11 +767,13 @@ static int error_type_set(void *data, u64 val) > > error_type = val; > > - return 0; > + return count; > }