]> git.baikalelectronics.ru Git - kernel.git/commit
devlink: report 0 after hitting end in region read
authorJacob Keller <jacob.e.keller@intel.com>
Tue, 4 Feb 2020 23:59:50 +0000 (15:59 -0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 5 Feb 2020 13:23:20 +0000 (14:23 +0100)
commit1a406d9242ef6846a9e1c86a2f4ec375d73a4029
treef4630b4af06e93b1c6ee8863973e1335c74a7be1
parent3e4d6dcf4df1d97e2e792bd0197b832221abd5db
devlink: report 0 after hitting end in region read

commit e1a601e56900 ("devlink: Return right error code in case of errors
for region read") modified the region read code to report errors
properly in unexpected cases.

In the case where the start_offset and ret_offset match, it unilaterally
converted this into an error. This causes an issue for the "dump"
version of the command. In this case, the devlink region dump will
always report an invalid argument:

000000000000ffd0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
000000000000ffe0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
devlink answers: Invalid argument
000000000000fff0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

This occurs because the expected flow for the dump is to return 0 after
there is no further data.

The simplest fix would be to stop converting the error code to -EINVAL
if start_offset == ret_offset. However, avoid unnecessary work by
checking for when start_offset is larger than the region size and
returning 0 upfront.

Fixes: e1a601e56900 ("devlink: Return right error code in case of errors for region read")
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/devlink.c