Re: [PATCH] bcache: Correct return value for sysfs attach errors

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

 



On 2017/6/13 上午5:18, Tony Asleson wrote:
> If you encounter any errors in bch_cached_dev_attach it will return a negative
> error code.  The variable 'v' which stores the result is unsigned, thus user
> space sees a very large value returned for bytes written which can cause
> incorrect user space behavior.  Utilize 1 signed variable to use throughout
> the function to preserve error return capability.
> 
> Signed-off-by: Tony Asleson <tasleson@xxxxxxxxxx>

Acked-by: Coly Li <colyli@xxxxxxx>

Nice catch, thanks.

Coly

> ---
>  drivers/md/bcache/sysfs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
> index f90f136..ab2f8ce 100644
> --- a/drivers/md/bcache/sysfs.c
> +++ b/drivers/md/bcache/sysfs.c
> @@ -192,7 +192,7 @@
>  {
>  	struct cached_dev *dc = container_of(kobj, struct cached_dev,
>  					     disk.kobj);
> -	unsigned v = size;
> +	ssize_t v = size;
>  	struct cache_set *c;
>  	struct kobj_uevent_env *env;
>  
> @@ -227,7 +227,7 @@
>  		bch_cached_dev_run(dc);
>  
>  	if (attr == &sysfs_cache_mode) {
> -		ssize_t v = bch_read_string_list(buf, bch_cache_modes + 1);
> +		v = bch_read_string_list(buf, bch_cache_modes + 1);
>  
>  		if (v < 0)
>  			return v;
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-bcache" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux ARM Kernel]     [Linux Filesystem Development]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]

  Powered by Linux