]> git.baikalelectronics.ru Git - kernel.git/commit
IB/core: fix null pointer deref and mem leak in error handling
authorColin Ian King <colin.king@canonical.com>
Wed, 1 Jun 2016 18:06:36 +0000 (19:06 +0100)
committerDoug Ledford <dledford@redhat.com>
Mon, 6 Jun 2016 23:22:18 +0000 (19:22 -0400)
commitf3476b40047d7b0242d2b9bc9e0f6e88299360a2
treef11bcfbdf15e37a0998c16ebdde94ad070448350
parent07d3a8f272743c576965b07df6fa41a68e764993
IB/core: fix null pointer deref and mem leak in error handling

The current error handling in setup_hw_stats has a couple of issues.
It is possible to generate a null pointer deference on the
kfree of hsag->attrs[i] because two of the early error exit paths
jump to the kfree when hsags NULL and not allocated. Fix this by
moving the kfree on stats and jumping to that, avoiding the hsag
freeing.

Secondly, there is a memory leak of stats if the hsag allocation
fails; instead of returning, jump to the kfree on stats.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/core/sysfs.c