Linux IIO development
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.14 06/12] iio: core: Use min() instead of min_t() to make code more robust
       [not found] <20230909004115.3581195-1-sashal@kernel.org>
@ 2023-09-09  0:41 ` Sasha Levin
  2023-09-10 13:23   ` Jonathan Cameron
  0 siblings, 1 reply; 2+ messages in thread
From: Sasha Levin @ 2023-09-09  0:41 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Andy Shevchenko, Nuno Sa, Jonathan Cameron, Sasha Levin, jic23,
	linux-iio

From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

[ 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>
---
 drivers/iio/industrialio-core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 97b7266ee0ffa..12d73ebcadfa3 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -328,7 +328,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;
 
-- 
2.40.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH AUTOSEL 4.14 06/12] iio: core: Use min() instead of min_t() to make code more robust
  2023-09-09  0:41 ` [PATCH AUTOSEL 4.14 06/12] iio: core: Use min() instead of min_t() to make code more robust Sasha Levin
@ 2023-09-10 13:23   ` Jonathan Cameron
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Cameron @ 2023-09-10 13:23 UTC (permalink / raw)
  To: Sasha Levin
  Cc: linux-kernel, stable, Andy Shevchenko, Nuno Sa, Jonathan Cameron,
	linux-iio

On Fri,  8 Sep 2023 20:41:09 -0400
Sasha Levin <sashal@kernel.org> wrote:

> From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> [ 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>

Whilst this was a good cleanup set from Andy, I don't think there was
any suggestion that it actually fixed any bugs?

As such I'd consider these (harmless) noise for stable.

Jonathan

> ---
>  drivers/iio/industrialio-core.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 97b7266ee0ffa..12d73ebcadfa3 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -328,7 +328,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;
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-09-10 13:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20230909004115.3581195-1-sashal@kernel.org>
2023-09-09  0:41 ` [PATCH AUTOSEL 4.14 06/12] iio: core: Use min() instead of min_t() to make code more robust Sasha Levin
2023-09-10 13:23   ` Jonathan Cameron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox