Skip to content

Commit d5b90e9

Browse files
jacob-kellerdavem330
authored andcommitted
devlink: report 0 after hitting end in region read
commit fdd41ec ("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: fdd41ec ("devlink: Return right error code in case of errors for region read") Signed-off-by: Jacob Keller <[email protected]> Acked-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 33e2b32 commit d5b90e9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/core/devlink.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3986,6 +3986,12 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb,
39863986
goto out_unlock;
39873987
}
39883988

3989+
/* return 0 if there is no further data to read */
3990+
if (start_offset >= region->size) {
3991+
err = 0;
3992+
goto out_unlock;
3993+
}
3994+
39893995
hdr = genlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq,
39903996
&devlink_nl_family, NLM_F_ACK | NLM_F_MULTI,
39913997
DEVLINK_CMD_REGION_READ);

0 commit comments

Comments
 (0)