]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
nfp: fix swapped arguments in nfp_encode_basic_qdr() calls
authorAlexey Kodanev <aleksei.kodanev@bell-sw.com>
Wed, 22 Apr 2026 16:05:36 +0000 (16:05 +0000)
committerJakub Kicinski <kuba@kernel.org>
Thu, 23 Apr 2026 18:01:20 +0000 (11:01 -0700)
commit4078c5611d7585548b249377ebd60c272e410490
tree1aa13220063af2720967ca052b3a41eed29a1327
parent5a8db80f721deee8e916c2cfdee78decda02ce4f
nfp: fix swapped arguments in nfp_encode_basic_qdr() calls

There is a mismatch between the passed arguments and the actual
nfp_encode_basic_qdr() function parameter names:

  static int nfp_encode_basic_qdr(u64 addr, int dest_island, int cpp_tgt,
                                  int mode, bool addr40, int isld1,
                                  int isld0)
  {
      ...

But "dest_island" and "cpp_tgt" are swapped at every call-site.
For example:

  return nfp_encode_basic_qdr(*addr, cpp_tgt, dest_island,
                              mode, addr40, isld1, isld0);

As a result, nfp_encode_basic_qdr() receives "dest_island" as CPP target
type, which is always NFP_CPP_TARGET_QDR(2) for these calls, and "cpp_tgt"
as the destination island ID, which can accidentally match or be outside
the valid NFP_CPP_TARGET_* types (e.g. '-1' for any destination).

Since code already worked for years, also add extra pr_warn() to error
paths in nfp_encode_basic_qdr() to help identify any potential address
verification failures.

Detected using the static analysis tool - Svace.

Fixes: 4cb584e0ee7d ("nfp: add CPP access core")
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Link: https://patch.msgid.link/20260422160536.61855-1-aleksei.kodanev@bell-sw.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_target.c