]> git.baikalelectronics.ru Git - kernel.git/commit
net/mlx4_core: Fix error handling when initializing CQ bufs in the driver
authorJack Morgenstein <jackm@dev.mellanox.co.il>
Tue, 22 Jan 2019 13:19:45 +0000 (15:19 +0200)
committerDavid S. Miller <davem@davemloft.net>
Fri, 25 Jan 2019 05:48:26 +0000 (21:48 -0800)
commita0a7cec276fe14d5ae4f37ddf74c01d52e35e68f
treee9b2e1b938d419d8e82a6e06353f864fea665d52
parentf6ee6be84e777c38a9580c6788a58f2362a460a6
net/mlx4_core: Fix error handling when initializing CQ bufs in the driver

Procedure mlx4_init_user_cqes() handles returns by copy_to_user
incorrectly. copy_to_user() returns the number of bytes not copied.
Thus, a non-zero return should be treated as a -EFAULT error
(as is done elsewhere in the kernel). However, mlx4_init_user_cqes()
error handling simply returns the number of bytes not copied
(instead of -EFAULT).

Note, though, that this is a harmless bug: procedure mlx4_alloc_cq()
(which is the only caller of mlx4_init_user_cqes()) treats any
non-zero return as an error, but that returned error value is processed
internally, and not passed further up the call stack.

In addition, fixes the following sparse warning:
warning: incorrect type in argument 1 (different address spaces)
   expected void [noderef] <asn:1>*to
   got void *buf

Fixes: fdd3838ba233 ("{net, IB}/mlx4: Initialize CQ buffers in the driver when possible")
Reported by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jack Morgenstein <jackm@dev.mellanox.co.il>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/cq.c