Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp313425qtb; Wed, 19 Oct 2022 02:37:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM44JEsG85t7fmkVXK4gYOYoIbQNfB4+UpaRryYd36pUiYq+LIuqKkoz6+En2sg0w6voyQDC X-Received: by 2002:a17:906:8a79:b0:78d:9c52:2196 with SMTP id hy25-20020a1709068a7900b0078d9c522196mr6060703ejc.328.1666172228834; Wed, 19 Oct 2022 02:37:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172228; cv=none; d=google.com; s=arc-20160816; b=jJZ4rQwCipQeQ1N+rRZ7O9nhOYBKWgYWIXOApOlW4RuGq9DtLecFFRhpCQha56YZJL pJsWq3W5CFx10vhHqT7aNOaWbLaER5pXXdsoLu+cSwPcd842rof0mSwQWVx2Yom5IRX2 tRu1njUpuSHR9MpaBzb12htOkoTlzLhbTg1rwtqdEMsX/5myF6V3JSazwot4ebaZ6hSP U+Yu17SX4yuMv68UwW/XpoW2IbyI0BEcDUNA5/mVzwOrGmE14Diwk/Lxw7wYUt7OjcAG l+LM24umQkx5b+XPowd9lxv/IyJmmfFf7JRlHIK8hZCcSJcr/dPrFAm9AN9wDZCj0HfV 4QuA== 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=Fe+LS5Do8r0e1/X8pwyPSNlaqXicuOA8anj64SGc1WE=; b=y20nBVqLEsM60oxAX3E1i8ezAOaOKkyrLzEY048B3rOLmcjgiWCSt9errcVz2FHn4p bEIrhORpp+xnMb2LV57CXmd3rouGFw9QNIOvqBzlpNise1LZKFlU8LS/wb7LUKI0fhny pgQIOK05PRluWVSijdELVnCsz8gipJ7jHclPFFV0tayYJa2YQoQr/Zuz59hAmJ2XDBjh 02hJo1ttIqNN6ZX4ZEGewsyZ4aTnXfCKie88CmzYuR8eCTIQFm/ZNb224DMdd3E95H/0 3BNePO+7hj8JYPJLAsdEjBAoXWNBKD+t1vEpXpI1mf/GTXudzG/sX8L0AjYHItZrfzSF GeVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ipiV0pNl; 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 n21-20020aa7c795000000b004513abe8f74si11797673eds.249.2022.10.19.02.36.42; Wed, 19 Oct 2022 02:37:08 -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=ipiV0pNl; 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 S232923AbiJSJMW (ORCPT + 99 others); Wed, 19 Oct 2022 05:12:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232907AbiJSJJf (ORCPT ); Wed, 19 Oct 2022 05:09:35 -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 06E2D6888F; Wed, 19 Oct 2022 02:00:31 -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 850CD617D6; Wed, 19 Oct 2022 09:00:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 936E1C433D6; Wed, 19 Oct 2022 09:00:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170024; bh=DC/OKbNo75HLtAcJhoT1fSpScx56M0NZEY5Sod8yCsc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ipiV0pNldvy3tHL1xW0Clo/SHkJ14GJu2uqloFlWH+q74dvK7jYR3iKgzdxNly6LS 4Ijxbggo5ARj+bWHqp6zSijhk7rh+A/MGVbFH8OGDyyDebIR9WsxT9NId9pd7B7gtQ Wni5XU0zqISztn3/w1SMSUSxPMBaI7k1SSxm7x3A= 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 6.0 499/862] RDMA/rxe: Fix the error caused by qp->sk Date: Wed, 19 Oct 2022 10:29:46 +0200 Message-Id: <20221019083312.029376671@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@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.4 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 fda03f9f03ed..d776dfda43b1 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -835,8 +835,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