drm/amdgpu: fix i2s_pdata out of bound array access
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix i2s_pdata out of bound array access
Fixed following Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:393 acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3 drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:396 acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3
--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0 -8
@@ -390,14 +390,6 @@ static int acp_hw_init(void *handle) i2s_pdata[2 ].i2s_reg_comp1 =ACP_BT_COMP1_REG_OFFSET ; i2s_pdata[2 ].i2s_reg_comp2 =ACP_BT_COMP2_REG_OFFSET ; - i2s_pdata[3 ].quirks =DW_I2S_QUIRK_COMP_REG_OFFSET ; -switch (adev->asic_type) { -case CHIP_STONEY : - i2s_pdata[3 ].quirks |=DW_I2S_QUIRK_16BIT_IDX_OVERRIDE ; -break ; -default : -break ; - } adev->acp.acp_res[0 ].name ="acp2x_dma" ; adev->acp.acp_res[0 ].flags =IORESOURCE_MEM ; adev->acp.acp_res[0 ].start = acp_base;
Signature · 1 line
2.25.1
Quoted 20 lines · Vijendar Mukunda
Fixed following Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:393acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:396acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3Reported-by Dan Carpenter <[email protected]>Signed-off-by Vijendar Mukunda <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 8 -------- 1 file changed, 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-0@@ -390,14 +390,6 @@ static int acp_hw_init(void *handle) i2s_pdata[2 ].i2s_reg_comp1 =ACP_BT_COMP1_REG_OFFSET ;
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c static int acp_hw_init(void *handle) · line 400
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-8i2s_pdata[2 ].i2s_reg_comp2 =ACP_BT_COMP2_REG_OFFSET ; - i2s_pdata[3 ].quirks =DW_I2S_QUIRK_COMP_REG_OFFSET ; -switch (adev->asic_type) { -case CHIP_STONEY : - i2s_pdata[3 ].quirks |=DW_I2S_QUIRK_16BIT_IDX_OVERRIDE ; -break ; -default : -break ; - }
Is this actually not used or should we just increase the allocation size?
Alex
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-1adev->acp.acp_res[0 ].name ="acp2x_dma" ; adev->acp.acp_res[0 ].flags =IORESOURCE_MEM ; adev->acp.acp_res[0 ].start = acp_base; --2.25.1
Quoted 35 lines · Alex Deucher
Quoted 20 lines · Vijendar Mukunda
Fixed following Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:393acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:396acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3Reported-by Dan Carpenter <[email protected]>Signed-off-by Vijendar Mukunda <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 8 -------- 1 file changed, 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-0@@ -390,14 +390,6 @@ static int acp_hw_init(void *handle) i2s_pdata[2 ].i2s_reg_comp1 =ACP_BT_COMP1_REG_OFFSET ;drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c static int acp_hw_init(void *handle) · line 400
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-8i2s_pdata[2 ].i2s_reg_comp2 =ACP_BT_COMP2_REG_OFFSET ; - i2s_pdata[3 ].quirks =DW_I2S_QUIRK_COMP_REG_OFFSET ; -switch (adev->asic_type) { -case CHIP_STONEY : - i2s_pdata[3 ].quirks |=DW_I2S_QUIRK_16BIT_IDX_OVERRIDE ; -break ; -default : -break ; - }Is this actually not used or should we just increase the allocation size?
Quoted 1 line
Alex
it's my bad. i2s_pdata array size is 3. when we recently included code changes for JD platform , this piece of code was added mistakenly for Stoney platform switch case.
--
Vijendar
Quoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-1adev->acp.acp_res[0 ].name ="acp2x_dma" ; adev->acp.acp_res[0 ].flags =IORESOURCE_MEM ; adev->acp.acp_res[0 ].start = acp_base; --2.25.1
Alex Deucher
Acked-byQuoted 37 lines · Mukunda,Vijendar
Quoted 35 lines · Alex Deucher
Quoted 20 lines · Vijendar Mukunda
Fixed following Smatch static checker warning:
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:393acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c:396acp_hw_init()
error: buffer overflow 'i2s_pdata' 3 <= 3Reported-by Dan Carpenter <[email protected]>Signed-off-by Vijendar Mukunda <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 8 -------- 1 file changed, 8 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-0@@ -390,14 +390,6 @@ static int acp_hw_init(void *handle) i2s_pdata[2 ].i2s_reg_comp1 =ACP_BT_COMP1_REG_OFFSET ;drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c static int acp_hw_init(void *handle) · line 400
Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-8i2s_pdata[2 ].i2s_reg_comp2 =ACP_BT_COMP2_REG_OFFSET ; - i2s_pdata[3 ].quirks =DW_I2S_QUIRK_COMP_REG_OFFSET ; -switch (adev->asic_type) { -case CHIP_STONEY : - i2s_pdata[3 ].quirks |=DW_I2S_QUIRK_16BIT_IDX_OVERRIDE ; -break ; -default : -break ; - }Is this actually not used or should we just increase the allocation size?
Quoted 4 lines
Quoted 1 line
Alex
it's my bad.
i2s_pdataarray size is 3. when we recently included code changes for JD platform , this piece of code was added mistakenly for Stoney platform switch case.
Thanks. Patch is:
Quoted 12 lines
--
VijendarQuoted 7 lines
Quoted 7 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +0
-1adev->acp.acp_res[0 ].name ="acp2x_dma" ; adev->acp.acp_res[0 ].flags =IORESOURCE_MEM ; adev->acp.acp_res[0 ].start = acp_base; --2.25.1