Skip to content

Commit

Permalink
block: sed-opal: fix u64 short atom length
Browse files Browse the repository at this point in the history
The length must be given as bytes and not as 4 bit tuples.

Reviewed-by: Scott Bauer <scott.bauer@intel.com>
Signed-off-by: Jonas Rabenstein <jonas.rabenstein@studium.uni-erlangen.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jonas Rabenstein authored and Jens Axboe committed Mar 16, 2018
1 parent 17cb960 commit 5f990d3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions block/sed-opal.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,26 +554,23 @@ static void add_token_u64(int *err, struct opal_dev *cmd, u64 number)

size_t len;
int msb;
u8 n;

if (!(number & ~TINY_ATOM_DATA_MASK)) {
add_token_u8(err, cmd, number);
return;
}

msb = fls(number);
len = DIV_ROUND_UP(msb, 4);
msb = fls64(number);
len = DIV_ROUND_UP(msb, 8);

if (cmd->pos >= IO_BUFFER_LENGTH - len - 1) {
pr_debug("Error adding u64: end of buffer.\n");
*err = -ERANGE;
return;
}
add_short_atom_header(cmd, false, false, len);
while (len--) {
n = number >> (len * 8);
add_token_u8(err, cmd, n);
}
while (len--)
add_token_u8(err, cmd, number >> (len * 8));
}

static void add_token_bytestring(int *err, struct opal_dev *cmd,
Expand Down

0 comments on commit 5f990d3

Please sign in to comment.