[PATCH 2/2] drm/amdgpu: fix uninitialized variable warning

Christian König christian.koenig at amd.com
Tue Apr 23 06:04:59 UTC 2024


Am 23.04.24 um 07:33 schrieb Bob Zhou:
> Because the val isn't initialized, a random variable is set by amdgpu_i2c_put_byte.
> So fix the uninitialized issue.

Well that isn't correct. See the code here:

         amdgpu_i2c_get_byte(amdgpu_connector->router_bus,
                             amdgpu_connector->router.i2c_addr,
                             0x3, &val);
         val &= ~amdgpu_connector->router.cd_mux_control_pin;
         amdgpu_i2c_put_byte(amdgpu_connector->router_bus,
                             amdgpu_connector->router.i2c_addr,
                             0x3, val);

The value is first read by amdgpu_i2c_get_byte(), then modified and then 
written again by amdgpu_i2c_put_byte().

Was this an automated warning?

Either way the patch is clearly rejected.

Regards,
Christian.

>
> Signed-off-by: Bob Zhou <bob.zhou at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
> index 82608df43396..d4d2dc792b60 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_i2c.c
> @@ -368,7 +368,7 @@ amdgpu_i2c_router_select_ddc_port(const struct amdgpu_connector *amdgpu_connecto
>   void
>   amdgpu_i2c_router_select_cd_port(const struct amdgpu_connector *amdgpu_connector)
>   {
> -	u8 val;
> +	u8 val = 0;
>   
>   	if (!amdgpu_connector->router.cd_valid)
>   		return;



More information about the amd-gfx mailing list