Skip to content

Commit c3dfcdb

Browse files
Wen Gukuba-moo
authored andcommitted
net/smc: fix incorrect SMC-D link group matching logic
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]>
1 parent fcf67d8 commit c3dfcdb

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
@@ -1877,9 +1877,15 @@ static bool smcd_lgr_match(struct smc_link_group *lgr,
18771877
struct smcd_dev *smcismdev,
18781878
struct smcd_gid *peer_gid)
18791879
{
1880-
return lgr->peer_gid.gid == peer_gid->gid && lgr->smcd == smcismdev &&
1881-
smc_ism_is_virtual(smcismdev) ?
1882-
(lgr->peer_gid.gid_ext == peer_gid->gid_ext) : 1;
1880+
if (lgr->peer_gid.gid != peer_gid->gid ||
1881+
lgr->smcd != smcismdev)
1882+
return false;
1883+
1884+
if (smc_ism_is_virtual(smcismdev) &&
1885+
lgr->peer_gid.gid_ext != peer_gid->gid_ext)
1886+
return false;
1887+
1888+
return true;
18831889
}
18841890

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

0 commit comments

Comments
 (0)