Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp3881297rwi; Sat, 22 Oct 2022 01:28:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6rA6WYepEPSARRvcmlx7Ny5SRRRHB13SBESJieKE4AV9EQGPsbkSiW92ZbolXRwCFI5LgC X-Received: by 2002:a17:903:284:b0:185:5537:f356 with SMTP id j4-20020a170903028400b001855537f356mr23147773plr.32.1666427321662; Sat, 22 Oct 2022 01:28:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666427321; cv=none; d=google.com; s=arc-20160816; b=L5dYgeGTx9+wlTDGXsi3X0T5iD3N+oCB3BOtYh4ZQrgJyiA89XzWS6PH0p54Vc105V 7aKRnOvcXr7bVFimCO0sehbpGLeH9ePHxHttcYCEZXz1wMLmDKOwo6ZyZmUoPz5RMbpF f4T2amKrBTGTa4FFGaHV+T3pa/K9Nft/4JTc7WY8vNFckNmNG8dBgRD+kmUmZSN1+WSj WzMulYoUy4kMFxtYFI3HmOYkXIgF0+tt96vcU0p4bC+ko52ELKySZCoJfn9cDIL3pmcn HBmYEio/vXWtrWnFJ6ZP2s/t7NnyNbtUbnPT4A8f7TAIfjlgZV8UGvI1G21ZgFcPUFQE B0Dg== 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=Jo4LxztqhG3TGDeH/XBSdrhsmlnRSRXyUgIbFDGUZjo=; b=NuQRoVX1VyDX3fxHNiw57/s54DmFnwPD7+YX61tvmQIacVzt4Gp4SZkr26TgO4R+qC Ae6bjw7xuRjwmK3oevEdg7oqNNqHJgA0QIC94dT3iaX8ZvdPFrjxwqcbSM8P9m/jpR1Z b6d/15X70CujL3SuGnQCC42+53yeY39KNmu3jfZYAjXHG7WrcEIs99tqUqMC4KbcXaf6 T8F2zjx8Q+ZhVZBsReW+8YrHVupXYa2aHSsZaFo8WR7tXa6gfFMBxPX90+PierWaO+Cu hpFlxXgejLOwi4KTJ7ocR2iT7msNNEW3KGKSJX2xburLxz+z04431bNIkZkM7S/M0AXJ IR0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n3jgRCkX; 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 h6-20020a056a00218600b0056aafb43783si4915628pfi.155.2022.10.22.01.28.30; Sat, 22 Oct 2022 01:28:41 -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=n3jgRCkX; 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 S233502AbiJVIKD (ORCPT + 99 others); Sat, 22 Oct 2022 04:10:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbiJVIGC (ORCPT ); Sat, 22 Oct 2022 04:06:02 -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 E01812C6E3F; Sat, 22 Oct 2022 00:52:58 -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 A4C39B82DFD; Sat, 22 Oct 2022 07:52:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAD40C433C1; Sat, 22 Oct 2022 07:52:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425143; bh=3R8E4rVNPKIXYCymFwwbRF9R67xBhTsT1o8q8+WQvN4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3jgRCkXrqdR1QaEUPm9cXZxG13J/pF3Fx5F75ph581ly2CV6srx6vXMOaptXDgra qQ2G9jn0t9hyF6q0Ci4j6OzFr3k00lUUSq4MtBBOlT29yfD4LZEcDf/enH9UZkL7zw AWMIYs/UOamtZNoWtMh2mHgUzhev7L5/SMlxZGD0= 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 5.19 405/717] RDMA/rxe: Fix the error caused by qp->sk Date: Sat, 22 Oct 2022 09:24:44 +0200 Message-Id: <20221022072515.868172641@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@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.3 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 173a4253406b..3df2db893dd3 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -832,8 +832,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