Re: [PATCH 4/7] agp/ati: Return error from ati_create_page_map()

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

 



On 11/12/21 15:16, Thomas Zimmermann wrote:
> Fix the compiler warning
>
>   drivers/char/agp/ati-agp.c: In function 'ati_create_page_map':
>   drivers/char/agp/ati-agp.c:58:16: warning: variable 'err' set but not used [-Wunused-but-set-variable]
>     58 |         int i, err = 0;
>
> by returing the error to the caller.
>
> Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx>
> ---
>  drivers/char/agp/ati-agp.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c
> index 857b37141a07..785cc1ecf4e0 100644
> --- a/drivers/char/agp/ati-agp.c
> +++ b/drivers/char/agp/ati-agp.c
> @@ -55,7 +55,7 @@ static struct _ati_generic_private {
>
>  static int ati_create_page_map(struct ati_page_map *page_map)
>  {
> -	int i, err = 0;
> +	int i, err;
>
>  	page_map->real = (unsigned long *) __get_free_page(GFP_KERNEL);
>  	if (page_map->real == NULL)
> @@ -63,6 +63,8 @@ static int ati_create_page_map(struct ati_page_map *page_map)
>
>  	set_memory_uc((unsigned long)page_map->real, 1);
>  	err = map_page_into_agp(virt_to_page(page_map->real));
> +	if (err)
> +		goto err_free_page;

I'd suggest to not use goto here, but instead simply fold
in the free_page() and return.


>  	page_map->remapped = page_map->real;
>
>  	for (i = 0; i < PAGE_SIZE / sizeof(unsigned long); i++) {
> @@ -71,6 +73,10 @@ static int ati_create_page_map(struct ati_page_map *page_map)
>  	}
>
>  	return 0;
> +
> +err_free_page:
> +	free_page((unsigned long)page_map->real);
> +	return err;
>  }
>
>
>





[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux