Re: [PATCH v3 3/9] ACPI: APEI: EINJ: Fix kernel test robot sparse warning

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

 



On Mon, 10 Feb 2025 10:36:59 -0800
Zaid Alali <zaidal@xxxxxxxxxxxxxxxxxxxxxx> wrote:

> This patch fixes the kernel test robot warning reported here:
> https://lore.kernel.org/all/202410241620.oApALow5-lkp@xxxxxxxxx/
> 
> Signed-off-by: Zaid Alali <zaidal@xxxxxxxxxxxxxxxxxxxxxx>

Hi Zaid,

Why in the read direction use structures on the stack, but in the
write direction kmalloc them? I think they could all just be 
stack variables as they are all pretty small.

Jonathan

>  }
> @@ -444,8 +453,10 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
>  		return rc;
>  	apei_exec_ctx_set_input(&ctx, type);
>  	if (acpi5) {
> -		struct set_error_type_with_address *v5param = einj_param;
> +		struct set_error_type_with_address *v5param;
>  
> +		v5param = kmalloc(sizeof(*v5param), GFP_KERNEL);
As below. Not sure why you can't just use the stack for this.
It's not very big.

> +		memcpy_fromio(v5param, einj_param, sizeof(*v5param));
>  		v5param->type = type;
>  		if (type & ACPI5_VENDOR_BIT) {
>  			switch (vendor_flags) {
> @@ -490,15 +501,21 @@ static int __einj_error_inject(u32 type, u32 flags, u64 param1, u64 param2,
>  				break;
>  			}
>  		}
> +		memcpy_toio(einj_param, v5param, sizeof(*v5param));
> +		kfree(v5param);
>  	} else {
>  		rc = apei_exec_run(&ctx, ACPI_EINJ_SET_ERROR_TYPE);
>  		if (rc)
>  			return rc;
>  		if (einj_param) {
> -			struct einj_parameter *v4param = einj_param;
> +			struct einj_parameter *v4param;

Why kmalloc rather than on stack as you did for the reads?

>  
> +			v4param = kmalloc(sizeof(*v4param), GFP_KERNEL);
> +			memcpy_fromio(v4param, einj_param, sizeof(*v4param));
>  			v4param->param1 = param1;
>  			v4param->param2 = param2;
> +			memcpy_toio(einj_param, v4param, sizeof(*v4param));
> +			kfree(v4param);
>  		}
>  	}
>  	rc = apei_exec_run(&ctx, ACPI_EINJ_EXECUTE_OPERATION);





[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux