]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sdp: Prevent kernel crash if device init fails (plus bonus fix)
authorAmir Vadai <amirv@mellanox.co.il>
Tue, 23 Feb 2010 08:02:59 +0000 (10:02 +0200)
committerMukesh Kacker <mukesh.kacker@oracle.com>
Tue, 6 Oct 2015 12:04:48 +0000 (05:04 -0700)
If sdp_add_device() fails, there is no client data stored in the IB device,
leading to a kernel crash when a connection is being established. Fix this
by rejecting connections when the device is not initialized.

Also, fix a bad goto target in an error case early in sdp_init_qp().

Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
Signed-off-by: Amir Vadai <amirv@mellanox.co.il>
drivers/infiniband/ulp/sdp/sdp_cma.c

index cf69d9bb91d96e0bd6146a97cef90572a678d8bc..14bafac68f6c4f8471d27992408455ff03010827 100644 (file)
@@ -93,13 +93,18 @@ static int sdp_init_qp(struct sock *sk, struct rdma_cm_id *id)
                sdp_warn(sk, "recv sge's. capability: %d needed: %ld\n",
                        sdp_sk(sk)->max_sge, SDP_MAX_RECV_SKB_FRAGS + 1);
                rc = -ENOMEM;
-               goto err_tx;
+               goto err_rx;
        }
 
        qp_init_attr.cap.max_send_sge = sdp_sk(sk)->max_sge;
        sdp_dbg(sk, "Setting max send sge to: %d\n", sdp_sk(sk)->max_sge);
                
        sdp_sk(sk)->sdp_dev = ib_get_client_data(device, &sdp_client);
+       if (!sdp_sk(sk)->sdp_dev) {
+               sdp_warn(sk, "SDP not available on device %s\n", device->name);
+               rc = -ENODEV;
+               goto err_rx;
+       }
 
        rc = sdp_rx_ring_create(sdp_sk(sk), device);
        if (rc)