Commit c8367c4cd9de512d296fc557f121be62a43987f3
Committed by
Roland Dreier
1 parent
257313b2a8
Exists in
master
and in
7 other branches
IB/mad: Return EPROTONOSUPPORT when an RDMA device lacks the QP required
We had a script which was looping through the devices returned from ibstat and attempted to register a SMI agent on an ethernet device. This caused a kernel panic for IBoE devices that don't have QP0. Fix this by checking if the QP exists before using it. Signed-off-by: Ira Weiny <weiny2@llnl.gov> Acked-by: Sean Hefty <sean.hefty@intel.com> Signed-off-by: Roland Dreier <roland@purestorage.com>
Showing 1 changed file with 7 additions and 0 deletions Side-by-side Diff
drivers/infiniband/core/mad.c
... | ... | @@ -276,6 +276,13 @@ |
276 | 276 | goto error1; |
277 | 277 | } |
278 | 278 | |
279 | + /* Verify the QP requested is supported. For example, Ethernet devices | |
280 | + * will not have QP0 */ | |
281 | + if (!port_priv->qp_info[qpn].qp) { | |
282 | + ret = ERR_PTR(-EPROTONOSUPPORT); | |
283 | + goto error1; | |
284 | + } | |
285 | + | |
279 | 286 | /* Allocate structures */ |
280 | 287 | mad_agent_priv = kzalloc(sizeof *mad_agent_priv, GFP_KERNEL); |
281 | 288 | if (!mad_agent_priv) { |