From patchwork Mon Oct 24 11:30:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp420420wru; Mon, 24 Oct 2022 05:18:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7h2v8fUb8sKP1ZBfd0nJY9UjYek16dt/KFvj6fxk9LzcSm9aayrBNuKrcaf6MFlIKTXQnL X-Received: by 2002:a05:6402:298d:b0:451:5fc5:d423 with SMTP id eq13-20020a056402298d00b004515fc5d423mr29999891edb.102.1666613889936; Mon, 24 Oct 2022 05:18:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666613889; cv=none; d=google.com; s=arc-20160816; b=DJrvO9rdYef6VKPEsHlUG6uIwAycLgElE7+5/BngWqeBeAdo8PuFpnRA86fd5/3vnx pSNXfBJocpiWdxoP2e7NUK8jy/M8SCD1hvmS2Hb88gd7m9uFGP7MExznkiCoVC3Ih4eW TG2jYd/79EudZnuUcFQfX9ZLr8sHN5VuhDJ5DAatsPp1dZupMfTdtlIk0XoKWbAPuIh5 YJkOcX8Ey+BmDXfWE5Tp7qiKPfegsvcBuUyLR3QqKQobMZArXL1oP/kRR2JbBc/PzzXC 63dfBVlm71xrLUwaOAC8g+E3kWumQjQAnxH9VkHn90JcyPPBmhidKC5bhqbDWv3uFWce bb5A== 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=EjdTgTX2vfzuu3G2yCHfSirnv0E/PhqeH4FdaUVc4HQ=; b=rq7y2dHN63UMpWq/1IbHwV7Lkvyprgo/Y/LFFWt3AwC0pvIy6lRbXsANL33TBIE2IA L2QJKxz/YQoPuxY3EqGZ+RDTvdY4rMHeCcEKxx2mdOOEHNkYxDC9xGdSwY9hWMiZyKUy VPLFYDk76x6MOAm/cjFqFpc5nYa5DUnygmmfMp9ib8abhtG3jTSDW38Yyvvl0DYafJhp 0iYy8f18ou4rhZ2AMp6bo51SnZoPy34aI+F0ppVxbdoeQQX8//e7hrxKioOXDQvQCOB3 hh/9tu7VWUUbzwuRy16gQofkVoycaQZJ9fHFUeLvO6gZb9E0Lc0inQWbxn+0xalmWDq0 FseA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UFjOhmTu; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k6-20020a1709067ac600b0078dc5c888f1si22751940ejo.135.2022.10.24.05.17.46; Mon, 24 Oct 2022 05:18:09 -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=UFjOhmTu; 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 S230526AbiJXMHR (ORCPT + 99 others); Mon, 24 Oct 2022 08:07:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232968AbiJXMEp (ORCPT ); Mon, 24 Oct 2022 08:04:45 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1646B7CB66; Mon, 24 Oct 2022 04:51:02 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 4090061290; Mon, 24 Oct 2022 11:50:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51BD4C433C1; Mon, 24 Oct 2022 11:50:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612252; bh=xCxQdsIqbqTUrcEZF9unwa2f9VV/naFt7tQVh//Op7g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UFjOhmTuN2OE8W00d22bHJY+OFmYtmBKsQiQaGPCHW4wwk5PkZEWT7Lhxfy4/a8Jt /0OKuGzLbEwUhE0NCBfitP2Lt1gKHQpkl+6ijzy0GfygP/Fm2vfxbadVkIAJg+ss8J 2EXT0M9VK2+P3HTjWSeXFcdQihGt4nzFC7EDglwA= 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.14 127/210] RDMA/rxe: Fix the error caused by qp->sk Date: Mon, 24 Oct 2022 13:30:44 +0200 Message-Id: <20221024113001.102053019@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747571325967848017?= X-GMAIL-MSGID: =?utf-8?q?1747571325967848017?= 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 6647a1628953..2391b0e698a9 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -871,8 +871,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 */