From: Amir Vadai Date: Tue, 23 Feb 2010 08:02:59 +0000 (+0200) Subject: sdp: Prevent kernel crash if device init fails (plus bonus fix) X-Git-Tag: v4.1.12-92~264^2~5^2~216 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a09396f2aeb9559894505b881fa0a855e406849a;p=users%2Fjedix%2Flinux-maple.git sdp: Prevent kernel crash if device init fails (plus bonus fix) 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 Signed-off-by: Amir Vadai --- diff --git a/drivers/infiniband/ulp/sdp/sdp_cma.c b/drivers/infiniband/ulp/sdp/sdp_cma.c index cf69d9bb91d96..14bafac68f6c4 100644 --- a/drivers/infiniband/ulp/sdp/sdp_cma.c +++ b/drivers/infiniband/ulp/sdp/sdp_cma.c @@ -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)