* [PATCH][next] RDMA: check for null return from call to ib_get_client_data
@ 2019-06-20 13:50 Colin King
2019-06-20 15:02 ` Jason Gunthorpe
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2019-06-20 13:50 UTC (permalink / raw)
To: Doug Ledford, Jason Gunthorpe, Leon Romanovsky, Parav Pandit, linux-rdma
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
The return from ib_get_client_data can potentially be null, so add a null
check on umad_dev and return -ENODEV in this unlikely case to avoid any
null pointer deferences.
Addresses-Coverity: ("Dereference null return")
Fixes: 8f71bb0030b8 ("RDMA: Report available cdevs through RDMA_NLDEV_CMD_GET_CHARDEV")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
drivers/infiniband/core/user_mad.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 547090b41cfb..d78a35913824 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -1153,6 +1153,9 @@ static int ib_issm_get_nl_info(struct ib_device *ibdev, void *client_data,
struct ib_umad_device *umad_dev =
ib_get_client_data(ibdev, &umad_client);
+ if (!umad_dev)
+ return -ENODEV;
+
if (!rdma_is_port_valid(ibdev, res->port))
return -EINVAL;
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH][next] RDMA: check for null return from call to ib_get_client_data
2019-06-20 13:50 [PATCH][next] RDMA: check for null return from call to ib_get_client_data Colin King
@ 2019-06-20 15:02 ` Jason Gunthorpe
0 siblings, 0 replies; 2+ messages in thread
From: Jason Gunthorpe @ 2019-06-20 15:02 UTC (permalink / raw)
To: Colin King
Cc: Doug Ledford, Leon Romanovsky, Parav Pandit, linux-rdma,
kernel-janitors, linux-kernel
On Thu, Jun 20, 2019 at 02:50:52PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The return from ib_get_client_data can potentially be null, so add a null
> check on umad_dev and return -ENODEV in this unlikely case to avoid any
> null pointer deferences.
It would be a kernel bug if NULL is seen here.
Jason
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-20 15:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-20 13:50 [PATCH][next] RDMA: check for null return from call to ib_get_client_data Colin King
2019-06-20 15:02 ` Jason Gunthorpe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).