Re: [PATCH] mm: shmem: Fix variable type to int to evaluate negative conditions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Karan Sanghavi <karansanghvi98@xxxxxxxxx> writes:

> version variable captures return value from utf8_parse_version
> function which can be negative, but unsigned won't
> let it capture, thus missing the further checks on negative values.
>
> Fixes: 58e55efd6c72 ("tmpfs: Add casefold lookup support")
> Signed-off-by: Karan Sanghavi <karansanghvi98@xxxxxxxxx>
> ---
> Coverity Message:
> CID 1601569: (#1 of 1): Unsigned compared against 0 (NO_EFFECT)
> unsigned_compare: This less-than-zero comparison of an unsigned 
> value is never true. version < 0U


Reviewed-by: Gabriel Krisman Bertazi <gabriel@xxxxxxxxxx>

>
> Coverity Link:
> https://scan7.scan.coverity.com/#/project-view/10043/11354?selectedIssue=1601569
> ---
>  mm/shmem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 7987deb2be9b..17a1d4fa8870 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -4367,7 +4367,7 @@ static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *
>  				    bool latest_version)
>  {
>  	struct shmem_options *ctx = fc->fs_private;
> -	unsigned int version = UTF8_LATEST;
> +	int version = UTF8_LATEST;
>  	struct unicode_map *encoding;
>  	char *version_str = param->string + 5;
>  
>
> ---
> base-commit: 6d59cab07b8d74d0f0422b750038123334f6ecc2
> change-id: 20241111-unsignedcompare1601569-05b5932145ef
>
> Best regards,

-- 
Gabriel Krisman Bertazi




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux