Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3080829rwb; Mon, 15 Aug 2022 17:39:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR60fry/xlJyfGbibecv38Agu1b/g74qNIRK1MTxTBTbOV9pz8qJOsG6GbBerZZvaIbgxM4h X-Received: by 2002:a17:907:781a:b0:730:cd06:3572 with SMTP id la26-20020a170907781a00b00730cd063572mr11860606ejc.487.1660610349770; Mon, 15 Aug 2022 17:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660610349; cv=none; d=google.com; s=arc-20160816; b=b6PBkSHZchZewGxF6bLA/7MWacv+Nyk1Pb2H7Duebg6HpWagIutze2zCoQsLU2/nRy Dj1tOGW6nOAmtRYOjaiJqsVK23SlWV8CS73WFoge5/VNXtESF16MA6iisWzKuz4y2bby XGnJwhYI7d8nuVboMG3hV25899OOn9Z4NfJshxv25/DgMmucXWg8s7B1eOPPXX6aCRTN tIhmktd+SUNOzVEibH86HZMEsubi+0ucmwXn98vaze2ndyEAim0zHef6Z5Vzvjctzq/n C44tdQSatrz6vXSbomTg6VgbNiMNqPpTAJlhuDSeF43YjAI2KlzCeeSB+5y6xeFBczJo NaXQ== 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=Y4OOvPUEPLFk5CX3mcuLJcz7Ouo0hP53VltF1C+UbOg=; b=lv7AcSPbPwEdrB/7Ix9uOGpSfMJ48zJJ3NxxLbIijhxQHDtlt+8kBFKs4OnjIN08l8 pGUKPuNVuL+OApAtPAOb5+THLv8XYaJ7sZqp+OKNPIKl9gNB3cY2/5aWHwgmmg14+mFf zS6TqNiK6csCJ+eSbgcJmCXJctKm0CaISh7WLgDMHgaxmPrKc6ouDhfWS/AKo8SGSxJh 5l38gnAUXWIyut3M4MduL/2NZCXq7wEIxAnQiN+Ps8wX2LIs48BgknU7bX6zEu3jD91g EVMynOtTy+40brndHHS8Ic+4PpVO4oo9IlHTfSRWNpZLs3fVMFYnnJkjf1EFpem4n9kd sVWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TF5nKCiz; 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 j15-20020a05640211cf00b0043c40e2b258si10337852edw.248.2022.08.15.17.38.44; Mon, 15 Aug 2022 17:39: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=TF5nKCiz; 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 S243429AbiHOVvw (ORCPT + 99 others); Mon, 15 Aug 2022 17:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349486AbiHOVoL (ORCPT ); Mon, 15 Aug 2022 17:44:11 -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 ED3B110228B; Mon, 15 Aug 2022 12:29:49 -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 486B8B81062; Mon, 15 Aug 2022 19:29:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A0C6C433C1; Mon, 15 Aug 2022 19:29:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591787; bh=tSG5BZiS7wjhmXMXzV5/Gy6ukN5wWDyGwnZ1mUmPQps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TF5nKCizpYV1zk7jbvSLc46wrisoQGxdCeHMlHHLl+5j4nklmKNinWyMGqJ+GzdcM nUO5P9k6JDM1fnw8vT3mbfADwrjbTVaqnDq4o229B0MI/clSAwd+Os34Nbf3XqKBoC BTI053I2sPvA+s8yL5Jm5gMxQwW0rltnvCH4krtY= 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.18 0681/1095] RDMA/rxe: fix xa_alloc_cycle() error return value check again Date: Mon, 15 Aug 2022 20:01:20 +0200 Message-Id: <20220815180457.546859444@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 87066d04ed18..69db28944567 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -140,7 +140,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; @@ -168,7 +168,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