]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
IB/hfi1: Fix possible null-pointer dereference in _extend_sdma_tx_descs()
authorTuo Li <islituo@gmail.com>
Fri, 6 Aug 2021 13:30:29 +0000 (06:30 -0700)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 1 Oct 2021 09:31:05 +0000 (11:31 +0200)
commitd97bbac55c1c00a176c2b445481522cb34777b92
tree2818beda9e1834f91cd55187ddea07bb2d7622b0
parent13a2240d5f7b29b4a11dca095a9a514628fb0529
IB/hfi1: Fix possible null-pointer dereference in _extend_sdma_tx_descs()

BugLink: https://bugs.launchpad.net/bugs/1944756
[ Upstream commit cbe71c61992c38f72c2b625b2ef25916b9f0d060 ]

kmalloc_array() is called to allocate memory for tx->descp. If it fails,
the function __sdma_txclean() is called:
  __sdma_txclean(dd, tx);

However, in the function __sdma_txclean(), tx-descp is dereferenced if
tx->num_desc is not zero:
  sdma_unmap_desc(dd, &tx->descp[0]);

To fix this possible null-pointer dereference, assign the return value of
kmalloc_array() to a local variable descp, and then assign it to tx->descp
if it is not NULL. Otherwise, go to enomem.

Fixes: 7724105686e7 ("IB/hfi1: add driver files")
Link: https://lore.kernel.org/r/20210806133029.194964-1-islituo@gmail.com
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Tuo Li <islituo@gmail.com>
Tested-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Acked-by: Mike Marciniszyn <mike.marciniszyn@cornelisnetworks.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/infiniband/hw/hfi1/sdma.c