Skip to content

Commit

Permalink
iio: core: Use min() instead of min_t() to make code more robust
Browse files Browse the repository at this point in the history
[ Upstream commit cb1d17535061ca295903f97f5cb0af9db719c02c ]

min() has strict type checking and preferred over min_t() for
unsigned types to avoid overflow. Here it's unclear why min_t()
was chosen since both variables are of the same type. In any
case update to use min().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20230721170022.3461-5-andriy.shevchenko@linux.intel.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Santhosh <santhosh.user.why.red@gmail.com>
  • Loading branch information
andy-shev authored and user-why-red committed Jun 21, 2024
1 parent 6224d9c commit 3d0d0d9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/iio/industrialio-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ static ssize_t iio_debugfs_write_reg(struct file *file,
char buf[80];
int ret;

count = min_t(size_t, count, (sizeof(buf)-1));
count = min(count, sizeof(buf) - 1);
if (copy_from_user(buf, userbuf, count))
return -EFAULT;

Expand Down

0 comments on commit 3d0d0d9

Please sign in to comment.