]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commit
net: ipa: fix register write command validation
authorAlex Elder <elder@linaro.org>
Fri, 12 Feb 2021 14:34:00 +0000 (08:34 -0600)
committerSeth Forshee <seth.forshee@canonical.com>
Thu, 8 Apr 2021 20:42:48 +0000 (15:42 -0500)
commit83a5ce07637af2fdbca5820e74642c678bed5137
treea442c504b0891f44291308ee955cb55d14f22fd5
parentc8903895478744ec73c3d224d4dbe8476a5e4f59
net: ipa: fix register write command validation

BugLink: https://bugs.launchpad.net/bugs/1923069
[ Upstream commit 2d65ed76924bc772d3974b0894d870b1aa63b34a ]

In ipa_cmd_register_write_valid() we verify that values we will
supply to a REGISTER_WRITE IPA immediate command will fit in
the fields that need to hold them.  This patch fixes some issues
in that function and ipa_cmd_register_write_offset_valid().

The dev_err() call in ipa_cmd_register_write_offset_valid() has
some printf format errors:
  - The name of the register (corresponding to the string format
    specifier) was not supplied.
  - The IPA base offset and offset need to be supplied separately to
    match the other format specifiers.
Also make the ~0 constant used there to compute the maximum
supported offset value explicitly unsigned.

There are two other issues in ipa_cmd_register_write_valid():
  - There's no need to check the hash flush register for platforms
    (like IPA v4.2) that do not support hashed tables
  - The highest possible endpoint number, whose status register
    offset is computed, is COUNT - 1, not COUNT.

Fix these problems, and add some additional commentary.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
drivers/net/ipa/ipa_cmd.c