[PATCH] ocxl: Fix endiannes bug in read_afu_name()

Frederic Barrat fbarrat at linux.ibm.com
Tue Dec 11 02:54:15 AEDT 2018



Le 10/12/2018 à 16:10, Greg Kurz a écrit :
> The double word returned by read_afu_info(OCXL_DVSEC_TEMPL_NAME) contains
> four characters of the AFU name, read from the PCI config space, hence
> with a little-endian ordering. When composing the string, a big-endian
> system must swap the bytes so that the characters appear in the right
> order.
> 
> Do this with le32_to_cpu().
> 
> Signed-off-by: Greg Kurz <groug at kaod.org>
> ---

Thanks!

Acked-by: Frederic Barrat <fbarrat at linux.ibm.com>


>   drivers/misc/ocxl/config.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/misc/ocxl/config.c b/drivers/misc/ocxl/config.c
> index 57a6bb1fd3c9..b76198ba8630 100644
> --- a/drivers/misc/ocxl/config.c
> +++ b/drivers/misc/ocxl/config.c
> @@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
>   		if (rc)
>   			return rc;
>   		ptr = (u32 *) &afu->name[i];
> -		*ptr = val;
> +		*ptr = le32_to_cpu(val);
>   	}
>   	afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
>   	return 0;
> 



More information about the Linuxppc-dev mailing list