Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2207417iof; Tue, 7 Jun 2022 23:13:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAQHYD+sN0wt4ka3l+oeQAyNBZgPG4efFZpXvL9TUNr7iFPwXn9bKN5MYj7akrVowjpX87 X-Received: by 2002:a17:90b:1d04:b0:1e8:64e2:38c6 with SMTP id on4-20020a17090b1d0400b001e864e238c6mr20483518pjb.238.1654668793876; Tue, 07 Jun 2022 23:13:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668793; cv=none; d=google.com; s=arc-20160816; b=LGLVoJAeYKeNGBqfItCQ8LHAHqU9DSXSRRYr543aEvx/nMxYp6dIQTMh9AdZ3zMp5x 50wFPl3aBtZ5L7YUGKFmJmCNDqF1tBMktXKdkxlHUv7txBYeBipmSPbOTiT9k4tii2gG CF73W4CJGJBVsqbsqCcvZgRnxT14vWHbzFoCBTqgTwaU5B6USsOJlnkxXT98jDQQOlCm 2R0EiZmLOTf6ocdmfQGkP5SGXqyQoZDXxGRmFIwlzXIDtx2h6M/hmRski5xFw3NRBD9T n5kVBI0nR2bnihMQ+BHI47y3vNsV9Wb6s5ngbm8EC9lJPqKGhZ9IHYf2GzMi/VYmSCud B3ew== 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=o7zgrfa63nAXTNj68KlArVJBMRe4swm/M0fnFfIvk2A=; b=q43pndXKHRkJsYA4tS1No4HBCI1hACwr6EpVQtnuMRniXaNBEZnXra/S9MCdQMRUS+ vN8ogM2V66xDtlRJOL8MnjpcMwP3AySo0ywCUvx+iMSyMztBUPQPyR9nAhE2oR+5tQAB av1G1m4xukFdScqJVN1A5zUpuD/y4mqRqwCYyf3+ZcQ0RN/yckw4wntyVw3hz7DmGEI/ GYo3DlGDLIQTjBHyRZKV1543vo1MkUxtb7+AKVylA0ysjXlCZWHCPeJy/3tzi0yAltCw hH/ZfR3ZBDgMacrej+XwPt8eBewwJll/XbhDN6cFB/0Bgrm6G+tOU7XfD6cK+el0DAuj YYIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mVIeXRJr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id r194-20020a632bcb000000b003fba9436128si29271804pgr.697.2022.06.07.23.13.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:13:13 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mVIeXRJr; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B82FE3563AC; Tue, 7 Jun 2022 22:35:46 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1391080AbiFHBwN (ORCPT + 99 others); Tue, 7 Jun 2022 21:52:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382703AbiFGWDu (ORCPT ); Tue, 7 Jun 2022 18:03:50 -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 A6C6D252C0C; Tue, 7 Jun 2022 12:15: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 ams.source.kernel.org (Postfix) with ESMTPS id 307C5B822C0; Tue, 7 Jun 2022 19:15:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A17C2C385A2; Tue, 7 Jun 2022 19:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629329; bh=oXpLKd/DALznNGwvJ+rgzx7UyoKE6EsnxDc4+u+dhNg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mVIeXRJrmUotg0n5AH+6rcTLEAi/R7Rf6j1nVrmnDrlAxAN+WaSfSvgy7lWcyn0DE P3lKTFPF/YWDLvwtUl1eYQtaPBuSiDZOLZOMzJwSD/drKrsTULxNTHVReMNV4Q0HqA /CwUjRCgOGOHivfSKFBvLIOqUkVQ/1IMHC8PlOVQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.18 652/879] RDMA/rxe: Fix an error handling path in rxe_get_mcg() Date: Tue, 7 Jun 2022 19:02:50 +0200 Message-Id: <20220607165021.772480272@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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: Christophe JAILLET [ Upstream commit 7f60951ff4d1664dfa2c304d144d195989199ef3 ] The commit in the Fixes tag has shuffled some code. Now 'mcg_num' is incremented before the kzalloc(). So if the memory allocation fails, this increment must be undone. Fixes: a926a903b7dc ("RDMA/rxe: Do not call dev_mc_add/del() under a spinlock") Link: https://lore.kernel.org/r/fe137cd8b1f17593243aa73d59c18ea71ab9ee36.1653225896.git.christophe.jaillet@wanadoo.fr Signed-off-by: Christophe JAILLET Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_mcast.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_mcast.c b/drivers/infiniband/sw/rxe/rxe_mcast.c index 873a9b10307c..86cc2e18a7fd 100644 --- a/drivers/infiniband/sw/rxe/rxe_mcast.c +++ b/drivers/infiniband/sw/rxe/rxe_mcast.c @@ -206,8 +206,10 @@ static struct rxe_mcg *rxe_get_mcg(struct rxe_dev *rxe, union ib_gid *mgid) /* speculative alloc of new mcg */ mcg = kzalloc(sizeof(*mcg), GFP_KERNEL); - if (!mcg) - return ERR_PTR(-ENOMEM); + if (!mcg) { + err = -ENOMEM; + goto err_dec; + } spin_lock_bh(&rxe->mcg_lock); /* re-check to see if someone else just added it */ -- 2.35.1