Skip to contentSkip to conversation

Coverity: dm_dmub_sw_init(): Incorrect expression

DISCUSSION coverity-bot 2 participants 3 messages Jan 12, 2023 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20230111 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Tue Jan 10 14:32:57 2023 -0500
a7ab345149b8 ("drm/amd/display: Load DMUB microcode during early_init")

Coverity reported the following:

*** CID 1530544: Incorrect expression (IDENTICAL_BRANCHES) drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1951 in dm_dmub_sw_init() 1945

1946     	switch (adev->ip_versions[DCE_HWIP][0]) {
1947     	case IP_VERSION(2, 1, 0):
1948     		dmub_asic = DMUB_ASIC_DCN21;
1949     		break;
1950     	case IP_VERSION(3, 0, 0):
vvv     CID 1530544:  Incorrect expression  (IDENTICAL_BRANCHES)
vvv     The same code is executed regardless of whether "adev->ip_versions[GC_HWIP][0] == 656128U" is true, because the 'then' and 'else' branches are identical. Should one of the branches be modified, or the entire 'if' statement replaced?
1951     		if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 0))
1952     			dmub_asic = DMUB_ASIC_DCN30;
1953     		else
1954     			dmub_asic = DMUB_ASIC_DCN30;
1955     		break;
1956     	case IP_VERSION(3, 0, 1):

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

Addresses-Coverity-ID: 1530544 ("Incorrect expression")

Fixes a7ab345149b8 ("drm/amd/display: Load DMUB microcode during early_init")

Thanks for your attention!

Signature · 1 line
Coverity-bot
#1 lore raw

[AMD Official Use Only - General]

This particular one was fixed already in https://patchwork.freedesktop.org/patch/518050/ which got applied today.

Quoted 67 lines

-----Original Message-----
From: coverity-bot <[email protected]>
Sent: Thursday, January 12, 2023 16:25
To: Limonciello, Mario <[email protected]>
Cc: [email protected]; [email protected]; Siqueira, Rodrigo <[email protected]>; Li, Sun peng (Leo) <[email protected]>; Li, Roman <[email protected]>; Zuo, Jerry <[email protected]>; Wu, Hersen <[email protected]>; dri- [email protected]; Koenig, Christian <[email protected]>; Lazar, Lijo <[email protected]>; Pillai, Aurabindo <[email protected]>; Wentland, Harry <[email protected]>; Deucher, Alexander <[email protected]>; Daniel Vetter <[email protected]>; David Airlie <[email protected]>; Pan, Xinhui <[email protected]>; Wheeler, Daniel <[email protected]>; Gustavo A. R. Silva <[email protected]>; [email protected]; [email protected]
Subject: Coverity: dm_dmub_sw_init(): Incorrect expression

Hello!

This is an experimental semi-automated report about issues detected by Coverity from a scan of next-20230111 as part of the linux-next scan project:
https://scan.coverity.com/projects/linux-next-weekly-scan

You're getting this email because you were associated with the identified lines of code (noted below) that were touched by commits:

Tue Jan 10 14:32:57 2023 -0500
a7ab345149b8 ("drm/amd/display: Load DMUB microcode during early_init")

Coverity reported the following:

*** CID 1530544: Incorrect expression (IDENTICAL_BRANCHES) drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:1951 in dm_dmub_sw_init()
1945

1946     	switch (adev->ip_versions[DCE_HWIP][0]) {
1947     	case IP_VERSION(2, 1, 0):
1948     		dmub_asic = DMUB_ASIC_DCN21;
1949     		break;
1950     	case IP_VERSION(3, 0, 0):

vvv CID 1530544: Incorrect expression (IDENTICAL_BRANCHES)
vvv The same code is executed regardless of whether "adev-

Quoted 1 line

ip_versions[GC_HWIP][0] == 656128U" is true, because the 'then' and 'else'

branches are identical. Should one of the branches be modified, or the entire 'if' statement replaced?

1951     		if (adev->ip_versions[GC_HWIP][0] == IP_VERSION(10, 3, 0))
1952     			dmub_asic = DMUB_ASIC_DCN30;
1953     		else
1954     			dmub_asic = DMUB_ASIC_DCN30;
1955     		break;
1956     	case IP_VERSION(3, 0, 1):

If this is a false positive, please let us know so we can mark it as such, or teach the Coverity rules to be smarter. If not, please make sure fixes get into linux-next. :) For patches fixing this, please include these lines (but double-check the "Fixes" first):

Addresses-Coverity-ID: 1530544 ("Incorrect expression")

Fixes a7ab345149b8 ("drm/amd/display: Load DMUB microcode during

early_init")

Thanks for your attention!

--
Coverity-bot