Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp3162845qtb; Mon, 24 Oct 2022 07:08:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5v4UNrWP4MIeHtzvrOcNVvn8qxbW3q6ieRHT2XUGlZ1G/c3BmKZl50AAD189gmrXdVWl2W X-Received: by 2002:a17:907:2c59:b0:78d:8e03:134 with SMTP id hf25-20020a1709072c5900b0078d8e030134mr27100331ejc.310.1666620529286; Mon, 24 Oct 2022 07:08:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666620529; cv=none; d=google.com; s=arc-20160816; b=fY/f6DW4bxXC7B3s0OG/5LPI20TE1y4ciey7IVMVhn6OfPhk2U8Jn0FsFCLse6C5/s YZZs0vXDqyKqO1KrivoePZOvTt0IW3tLf/ZKZGZmtB9SRAu+6OAg+ilNxnN5GY+T0znS +eu/mQdlPBG4eyovVuGJP71BoC0o63NcPkcsIZKcVHraZrFDxCHVlrBSAGKpao0FvMnW 7lt3vwVTbqrKhNpa1eHZobFxEWquaKCvwREKDtH5zIVhpxowhjuw4mSlw1+ivHiMcrUH fWULbbisOZOvRQIcAj/hFgMPts5W9wUAbOw9xQmfe/MZo8kvoxmmRoASxgrNXc5HfiYd Jruw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=K0S0JXE2wXMMkn8Pe3of5LAlfgh3NxHiNp0tdJegV3g=; b=ZZyhJ1gZWtchzxjzh3knoyFsRG3qiS4t0O7Pozkj6DVa3mymvk0ZyLVAAR4nuTv7Tu g4jJMmDBy8DnpeZF33Hf2eAMfCItxbKHj7G+ma4j8eQs3ac3r9n+p+OdhT/LyfwwWv3t b0Yp4+ArY2y8RAJ3H0OO9kPCLGUtUygdN/z/qpZCXV7YBtN7J3YWHHhlU87lMGGALF9U ljlY9gJDUkQMn9oTLWpitm6MyRNM/zPXs3SAu5jfs/dCF3eL8kjddE7vuhZMMiD2Ctug YzXIkjU425Ki2tk28xQdUsG98gsrLWB9RNBjN/wlpFr1KHQVxNiadoeIQoH5M3xU9pCZ ilEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BacPQApB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v15-20020a170906180f00b0078d20d71475si24217125eje.413.2022.10.24.07.08.23; Mon, 24 Oct 2022 07:08:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BacPQApB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230355AbiJXMcs (ORCPT + 99 others); Mon, 24 Oct 2022 08:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234000AbiJXM3K (ORCPT ); Mon, 24 Oct 2022 08:29:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 010E987FBE; Mon, 24 Oct 2022 05:03:09 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 65C0DB81210; Mon, 24 Oct 2022 12:00:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47631C433C1; Mon, 24 Oct 2022 12:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612820; bh=3PV82GHpC9WdupZAWkWeg7H6UZNAeWVZotKsrI4jYoE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BacPQApB5PtmwaHaSF3DcBDwyfvCmuBtqG5pQvXnuVIGnbp4z1d+pkJzS2MkTxH9Q /q2K6XVhC7CK3gQHp9qicZhiaPoec6SkbPISS3ti/Q78ObZyYH/TbKN2x2pMjFwqmW DV3LcGSFFEwfFUrPM/WQImZjcFrsrTtZ5s0ev9uM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zhu Yanjun , Li Zhijian , Bob Pearson , Leon Romanovsky , Sasha Levin Subject: [PATCH 4.19 132/229] RDMA/rxe: Fix the error caused by qp->sk Date: Mon, 24 Oct 2022 13:30:51 +0200 Message-Id: <20221024113003.270299057@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112959.085534368@linuxfoundation.org> References: <20221024112959.085534368@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhu Yanjun [ Upstream commit 548ce2e66725dcba4e27d1e8ac468d5dd17fd509 ] When sock_create_kern in the function rxe_qp_init_req fails, qp->sk is set to NULL. Then the function rxe_create_qp will call rxe_qp_do_cleanup to handle allocated resource. Before handling qp->sk, this variable should be checked. Fixes: 8700e3e7c485 ("Soft RoCE driver") Link: https://lore.kernel.org/r/20220822011615.805603-3-yanjun.zhu@linux.dev Signed-off-by: Zhu Yanjun Reviewed-by: Li Zhijian Reviewed-by: Bob Pearson Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_qp.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_qp.c b/drivers/infiniband/sw/rxe/rxe_qp.c index 476871c8ae44..6320390f531c 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -841,8 +841,10 @@ static void rxe_qp_do_cleanup(struct work_struct *work) free_rd_atomic_resources(qp); - kernel_sock_shutdown(qp->sk, SHUT_RDWR); - sock_release(qp->sk); + if (qp->sk) { + kernel_sock_shutdown(qp->sk, SHUT_RDWR); + sock_release(qp->sk); + } } /* called when the last reference to the qp is dropped */ -- 2.35.1