IB/mlx4: fix improper return value
authorPan Bian <bianpan2016@163.com>
Sun, 4 Dec 2016 06:45:38 +0000 (14:45 +0800)
committerDoug Ledford <dledford@redhat.com>
Wed, 14 Dec 2016 19:35:23 +0000 (14:35 -0500)
commit46d0703fac3ffa12ec36f22f386d96d0f474c9c2
treec15928a73813d5eaf2e54f685d1e0814ae4d8311
parent5b4c9cd7e4790f37b595aeb4bf6fcbf7e3ba9e2c
IB/mlx4: fix improper return value

If uhw->inlen is non-zero, the value of variable err is 0 if the copy
succeeds. Then, if kzalloc() or kmalloc() returns a NULL pointer, it
will return 0 to the callers. As a result, the callers cannot detect the
errors. This patch fixes the bug, assign "-ENOMEM" to err before the
NULL pointer checks, and remove the initialization of err at the
beginning.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=189031
Signed-off-by: Pan Bian <bianpan2016@163.com>
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/mlx4/main.c