* [PATCH v3] infiniband: i40iw: fix a potential NULL pointer dereference
@ 2019-12-26 13:21 xiyuyang19
2019-12-26 14:40 ` Leon Romanovsky
2019-12-28 19:50 ` Markus Elfring
0 siblings, 2 replies; 3+ messages in thread
From: xiyuyang19 @ 2019-12-26 13:21 UTC (permalink / raw)
To: xiyuyang19
Cc: yuanxzhang, kjlu, leon, 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>
---
Changes in v2:
- Release rtnl lock when in_dev_get return NULL
Changes in v3:
- Continue the next loop when in_dev_get return NULL
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..2386143 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)
+ continue;
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] 3+ messages in thread
* Re: [PATCH v3] infiniband: i40iw: fix a potential NULL pointer dereference
2019-12-26 13:21 [PATCH v3] infiniband: i40iw: fix a potential NULL pointer dereference xiyuyang19
@ 2019-12-26 14:40 ` Leon Romanovsky
2019-12-28 19:50 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2019-12-26 14:40 UTC (permalink / raw)
To: xiyuyang19
Cc: yuanxzhang, kjlu, Xin Tan, Faisal Latif, Shiraz Saleem,
Doug Ledford, Jason Gunthorpe, linux-rdma, linux-kernel
On Thu, Dec 26, 2019 at 09:21:56PM +0800, xiyuyang19@fudan.edu.cn wrote:
> 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>
> ---
> Changes in v2:
> - Release rtnl lock when in_dev_get return NULL
> Changes in v3:
> - Continue the next loop when in_dev_get return NULL
>
> drivers/infiniband/hw/i40iw/i40iw_main.c | 2 ++
> 1 file changed, 2 insertions(+)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] infiniband: i40iw: fix a potential NULL pointer dereference
2019-12-26 13:21 [PATCH v3] infiniband: i40iw: fix a potential NULL pointer dereference xiyuyang19
2019-12-26 14:40 ` Leon Romanovsky
@ 2019-12-28 19:50 ` Markus Elfring
1 sibling, 0 replies; 3+ messages in thread
From: Markus Elfring @ 2019-12-28 19:50 UTC (permalink / raw)
To: Xiyu Yang, Xin Tan, linux-rdma
Cc: linux-kernel, Doug Ledford, Faisal Latif, Jason Gunthorpe,
Kangjie Lu, Leon Romanovsky, Shiraz Saleem, Yuan Zhang
> in_dev_get may return a NULL object.
I would prefer a wording like “A null pointer can be returned by in_dev_get().”.
> The fix handles the situation
> by adding a check to avoid NULL pointer dereference on idev,
> as pick_local_ipaddrs does.
How do you think about the wording suggestion “Thus add a corresponding check
so that a null pointer dereference will be avoided at this place.”?
Please add also the tag “Fixes” to your change description.
Regards,
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-28 19:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-26 13:21 [PATCH v3] infiniband: i40iw: fix a potential NULL pointer dereference xiyuyang19
2019-12-26 14:40 ` Leon Romanovsky
2019-12-28 19:50 ` Markus Elfring
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.