Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3273596rwb; Mon, 15 Aug 2022 22:57:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Xa9ZE7otHC+mQfVyk/gp0qhkLUWJeQdSUnqqpIaTmxIqV38JVPJMqCeLQ2gL1b/06gzD1 X-Received: by 2002:a17:906:8a78:b0:730:7a4f:fb36 with SMTP id hy24-20020a1709068a7800b007307a4ffb36mr12647360ejc.624.1660629468849; Mon, 15 Aug 2022 22:57:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660629468; cv=none; d=google.com; s=arc-20160816; b=VhIKE/2uev5NLYJyhYATGjgV7gVwflPxckteg9RAdGZCtQyLc6sbj1uKAPtTxVMhz9 1MYWHsgBXBwgkInblZNbbmlqHHmHnyLTW4l2InVZ3B9bZe6J+RCZ2cPMNODawRVDy95B 5Lqphd77yhVqZpKAofGoCJ8ka4Y83nxwUZClLBfzEkBtRtRsjcm6ajYWzaxfP5kb8fO9 2P1oH+4yF6anUNEr7cwGgB6Tl4a4KVZLmbNBCHmnSVWytWQ5QAyOrSvx6/YB+sYTqji5 F9Bq8u1/x9hS5J1Q+h7/pcmVpSEang7F2vKn1BI+dgz+ilUYFHUMvuOY4LH8k4dxtthO zmIw== 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=/L46CcUnLAFPrTrFgyVoLTQXPqEHRJwKA3ZNDm9n1pU=; b=wwUBfveDopM/lDXK9sUTQo5JCdnSIOkoR1c4JgfCAtR2XuV8xny4p3U7yFbrsTXLYI blq5FP9/1B/nVUOpjhzk3oqMoyi5NOcuz5GaNlNcNMQHasX0yE5MHIxeMNCHHuzuSG+h uqCnAGryHVwrhPEk6u0+ReueRGZKtyPgfUsEnHL+9S0hs2tOVKFjWoJ/z6WT5dhft6VV dYFI4zuguTZ8fSOhfHCWLmpwJ/7u5Evk5vRmBRbK62BUVFfJJwGNr66zUc0cVXL2anmI UNTeJzuAN+w/FTUu4q9TrkMvaDyBUG/Z8zlXSDMk5QOxjkkMUlzph9DrIY4FbfIcUgbb ND9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TkX+kFN4; 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 cs16-20020a170906dc9000b00738466b6883si4609337ejc.42.2022.08.15.22.57.23; Mon, 15 Aug 2022 22:57:48 -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=TkX+kFN4; 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 S231290AbiHPEjy (ORCPT + 99 others); Tue, 16 Aug 2022 00:39:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41118 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231432AbiHPEj1 (ORCPT ); Tue, 16 Aug 2022 00:39:27 -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 D8E16178296; Mon, 15 Aug 2022 13:30:21 -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 D258D6117D; Mon, 15 Aug 2022 20:30:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFE0EC433C1; Mon, 15 Aug 2022 20:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595420; bh=VivZCPU1afniD8ZTOxdtCPJ9hOkpVZBhg6LqCiB5X9M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TkX+kFN4xcD6FRNBnTq+OKH7qQ2fhzW3YtBL6ooJslK7i7GiAIAbxdvM5ewYjAUIq 8esne21d0CA+ZqfQvprVEzJ8kyEzYnWhFl09MWgL6dO7zboWaQZvrLPhfnsmo68UH8 0yaWdLbvtfNnhUm0FLo2Fn6vSvy8n9lkOgauUgUY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dongliang Mu , Bob Pearson , Leon Romanovsky , Sasha Levin Subject: [PATCH 5.19 0726/1157] RDMA/rxe: fix xa_alloc_cycle() error return value check again Date: Mon, 15 Aug 2022 20:01:22 +0200 Message-Id: <20220815180508.521051061@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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.1 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,T_SCC_BODY_TEXT_LINE 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: Dongliang Mu [ Upstream commit 1a685940e6200e9def6e34bbaa19dd31dc5aeaf8 ] Currently rxe_alloc checks ret to indicate error, but 1 is also a valid return and just indicates that the allocation succeeded with a wrap. Fix this by modifying the check to be < 0. Link: https://lore.kernel.org/r/20220609070656.1446121-1-dzm91@hust.edu.cn Fixes: 3225717f6dfa ("RDMA/rxe: Replace red-black trees by xarrays") Signed-off-by: Dongliang Mu Reviewed-by: Bob Pearson Signed-off-by: Leon Romanovsky Signed-off-by: Sasha Levin --- drivers/infiniband/sw/rxe/rxe_pool.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index 19b14826385b..e9f3bbd8d605 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -139,7 +139,7 @@ void *rxe_alloc(struct rxe_pool *pool) err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit, &pool->next, GFP_KERNEL); - if (err) + if (err < 0) goto err_free; return obj; @@ -167,7 +167,7 @@ int __rxe_add_to_pool(struct rxe_pool *pool, struct rxe_pool_elem *elem) err = xa_alloc_cyclic(&pool->xa, &elem->index, elem, pool->limit, &pool->next, GFP_KERNEL); - if (err) + if (err < 0) goto err_cnt; return 0; -- 2.35.1