]> git.baikalelectronics.ru Git - kernel.git/commit
cifs: fix a sign extension bug
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 21 Sep 2021 20:33:35 +0000 (23:33 +0300)
committerSteve French <stfrench@microsoft.com>
Wed, 22 Sep 2021 01:51:50 +0000 (20:51 -0500)
commit46d4df4fbf2760252827d0aa105aa55d0abc6ae6
tree733ed2ab3f3d856302b7aef5b1ff0557b0e5b2b3
parentaa712a094e7dced060db09ea4338ba8e1ac9910e
cifs: fix a sign extension bug

The problem is the mismatched types between "ctx->total_len" which is
an unsigned int, "rc" which is an int, and "ctx->rc" which is a
ssize_t.  The code does:

ctx->rc = (rc == 0) ? ctx->total_len : rc;

We want "ctx->rc" to store the negative "rc" error code.  But what
happens is that "rc" is type promoted to a high unsigned int and
'ctx->rc" will store the high positive value instead of a negative
value.

The fix is to change "rc" from an int to a ssize_t.

Fixes: a6ca12faa1fc ("CIFS: Add asynchronous write support through kernel AIO")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/cifs/file.c