public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] infiniband: i40iw: fix a potential NULL pointer dereference
@ 2019-12-26  2:52 xiyuyang19
  2019-12-26  8:14 ` Leon Romanovsky
  0 siblings, 1 reply; 2+ messages in thread
From: xiyuyang19 @ 2019-12-26  2:52 UTC (permalink / raw)
  To: xiyuyang19
  Cc: yuanxzhang, kjlu, Xin Tan, Faisal Latif, Shiraz Saleem,
	Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel

From: Xiyu Yang <xiyuyang19@fudan.edu.cn>

in_dev_get may return a NULL object. The fix handles the situation
by adding a check to avoid NULL pointer dereference on idev,
as pick_local_ipaddrs does.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
---
 drivers/infiniband/hw/i40iw/i40iw_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/infiniband/hw/i40iw/i40iw_main.c b/drivers/infiniband/hw/i40iw/i40iw_main.c
index d44cf33d..18587cc 100644
--- a/drivers/infiniband/hw/i40iw/i40iw_main.c
+++ b/drivers/infiniband/hw/i40iw/i40iw_main.c
@@ -1225,6 +1225,8 @@ static void i40iw_add_ipv4_addr(struct i40iw_device *iwdev)
 			const struct in_ifaddr *ifa;
 
 			idev = in_dev_get(dev);
+			if (!idev)
+				return;
 			in_dev_for_each_ifa_rtnl(ifa, idev) {
 				i40iw_debug(&iwdev->sc_dev, I40IW_DEBUG_CM,
 					    "IP=%pI4, vlan_id=%d, MAC=%pM\n", &ifa->ifa_address,
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-12-26  8:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-26  2:52 [PATCH] infiniband: i40iw: fix a potential NULL pointer dereference xiyuyang19
2019-12-26  8:14 ` Leon Romanovsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox