Skip to content

Commit 3706311

Browse files
Wen Gugregkh
authored andcommitted
net/smc: fix incorrect SMC-D link group matching logic
commit c3dfcdb upstream. The logic to determine if SMC-D link group matches is incorrect. The correct logic should be that it only returns true when the GID is the same, and the SMC-D device is the same and the extended GID is the same (in the case of virtual ISM). It can be fixed by adding brackets around the conditional (or ternary) operator expression. But for better readability and maintainability, it has been changed to an if-else statement. Reported-by: Matthew Rosato <[email protected]> Closes: https://lore.kernel.org/r/[email protected] Fixes: b40584d ("net/smc: compatible with 128-bits extended GID of virtual ISM device") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Wen Gu <[email protected]> Reviewed-by: Alexandra Winter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7a89f53 commit 3706311

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

net/smc/smc_core.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1889,9 +1889,15 @@ static bool smcd_lgr_match(struct smc_link_group *lgr,
18891889
struct smcd_dev *smcismdev,
18901890
struct smcd_gid *peer_gid)
18911891
{
1892-
return lgr->peer_gid.gid == peer_gid->gid && lgr->smcd == smcismdev &&
1893-
smc_ism_is_virtual(smcismdev) ?
1894-
(lgr->peer_gid.gid_ext == peer_gid->gid_ext) : 1;
1892+
if (lgr->peer_gid.gid != peer_gid->gid ||
1893+
lgr->smcd != smcismdev)
1894+
return false;
1895+
1896+
if (smc_ism_is_virtual(smcismdev) &&
1897+
lgr->peer_gid.gid_ext != peer_gid->gid_ext)
1898+
return false;
1899+
1900+
return true;
18951901
}
18961902

18971903
/* create a new SMC connection (and a new link group if necessary) */

0 commit comments

Comments
 (0)