From patchwork Mon Oct 24 11:30:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8446 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp401666wru; Mon, 24 Oct 2022 04:48:58 -0700 (PDT) X-Google-Smtp-Source: AMsMyM528AqOn+iTNXuD49sCGRkfVQz03tX9cDHR2wbxzfi/s4ZLkJDC+A1OGab9dZLqU+D2hGps X-Received: by 2002:a17:907:318b:b0:740:33f2:9e8 with SMTP id xe11-20020a170907318b00b0074033f209e8mr81379ejb.138.1666612137883; Mon, 24 Oct 2022 04:48:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666612137; cv=none; d=google.com; s=arc-20160816; b=JoG9kNehdEGiaYqBz1SP63HY4oKSrjY9MHywUb39vJyMx1e6E5W8TVeyv7Jfqux5Ab 4pAtW2xfHwap0tcctU+6bfF7/BhdHKM0AF0v3Q8o4GgyejI/izMoZhUujx1ZYos3NMih aJ+Js9bocytxpM+iaeXbQtM2G4uRpYge88nEAY7BZpAyMmQw9bMW5JzjRLBbkAX1ucuV bxZHt4lpXIhljSA8wKhlNWj1otOkyonMGVDEawYzlhJRQwSi4IY1GcPld86UbDjgEHQ1 9xBBxe0qwrMfLX+8Olp9cZcgr6jMReISiTkdBUe9idGuxj+8MW+4YJjIaH9/Sy6uyGyO bJfQ== 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=yRTMTqnu6TECaiJe/vHJXM//XQ7/1bsviV0C4HBTvOc=; b=bimxCBy9jtOVNHTnEbHDoAhf3p9xwOMVwTxGamiGx/7h/35hNxJp+mgcz/+SKxcZVP hU/Ixo9PdiaH1Sk03WySC1CTvuQ1rmZr/wqj8Q+IGf24GBqw+aEx/RpQvW3kkvX2yLFM hlpejyEOE9neRGuY0VzO5edpaILSure8IZt+c472btHBgtIDeqqt9axK5ME8vJESCRso eOIoUtYv70ri+XhvjkxZxE4HjbiNd/do72rfmNC00emXL2ypQtKKTLuizrl/WHOqV9wh FwUXfMwYECDNfRTVeOi97NeV2nyjKaBB3rQ5aorLw8dQl+J0q1wyRf/C2E71lvRn6fij yMlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=E4cZLlb+; 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 wz8-20020a170906fe4800b007aa0798e081si1315272ejb.394.2022.10.24.04.48.33; Mon, 24 Oct 2022 04:48:57 -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=E4cZLlb+; 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 S231728AbiJXLsB (ORCPT + 99 others); Mon, 24 Oct 2022 07:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230402AbiJXLrI (ORCPT ); Mon, 24 Oct 2022 07:47:08 -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 1355176546; Mon, 24 Oct 2022 04:42:59 -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 3164FB8117B; Mon, 24 Oct 2022 11:42:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 86282C433D6; Mon, 24 Oct 2022 11:42:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611762; bh=qYfc8472eOJ6mLmVF7VSLElhyX+9s5NbjPjxIy6+y+4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E4cZLlb+1thyFfN0wHO464YRmUIXhAhhcqRbagzWd71d4bbjXNwltDGqVFKcuHgGc ghZfKXsqSm9k8mR23lALEZu/WCpR2aW0HxdmghXwpRM1VWUWYNNdBKjs0ZAUMe0lpo E1/ac1pHwLnzFXLRQvlzVExbaw4cze+81faYL3UE= 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.9 101/159] RDMA/rxe: Fix the error caused by qp->sk Date: Mon, 24 Oct 2022 13:30:55 +0200 Message-Id: <20221024112953.125890105@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112949.358278806@linuxfoundation.org> References: <20221024112949.358278806@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?1747569488700186198?= X-GMAIL-MSGID: =?utf-8?q?1747569488700186198?= 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 d41728397bd2..4c91062ff247 100644 --- a/drivers/infiniband/sw/rxe/rxe_qp.c +++ b/drivers/infiniband/sw/rxe/rxe_qp.c @@ -864,6 +864,8 @@ void rxe_qp_cleanup(void *arg) 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); + } }