From patchwork Sun Dec 9 11:11:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuval Shaia X-Patchwork-Id: 10719977 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D106614E2 for ; Sun, 9 Dec 2018 11:12:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B90152A6C5 for ; Sun, 9 Dec 2018 11:12:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A70392A6CC; Sun, 9 Dec 2018 11:12:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3F85E2A6C5 for ; Sun, 9 Dec 2018 11:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726184AbeLILMB (ORCPT ); Sun, 9 Dec 2018 06:12:01 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:58232 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726079AbeLILMB (ORCPT ); Sun, 9 Dec 2018 06:12:01 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wB9B9WNH178931; Sun, 9 Dec 2018 11:11:53 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=qAtPa+PYiXS8ftA8imHmvJgGI56DA9vUSsSpa3PhBjo=; b=QpUXpCFlRhSEKiZf96PYDVkgKK3oLP4KIHdZSiRi8ryXvhAsw50xr9ZDlXGx9wWeoSs8 QGPvLJqPYT0W5uPN5mdr5x9aH8C6yjyQbtcrCXZopAJNub5eTNbgPDZwPflfC4w+mP/1 vkZK17JydBF2t4ZBsg65VCTIKrIVIj0/JQP3AvCrmxjRpFTHuMHT52VcwVpQicfwZFR5 0eDJ5tJh1kmAA2WJ6H3Woj1BYeA9xxUW170zYrTt6C9JpgOwWwLcDHuHZrfGecd8P/1s tQFMaHc9421gkGKdjJNUXPhFO+PLxldvmJsrZQcYFy5lWAx1XWcqMKW6M1BZqLX2Yodb 8Q== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2p86kqjapk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 09 Dec 2018 11:11:53 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id wB9BBqhs007046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 9 Dec 2018 11:11:52 GMT Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wB9BBpAT018126; Sun, 9 Dec 2018 11:11:51 GMT Received: from lap1.nl.oracle.com (/10.175.61.132) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Sun, 09 Dec 2018 03:11:50 -0800 From: Yuval Shaia To: monis@mellanox.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, parav@mellanox.com, bvanassche@acm.org, leon@kernel.org Cc: Yuval Shaia Subject: [PATCH v3] IB/rxe: Fix incorrect cache cleanup in error flow Date: Sun, 9 Dec 2018 13:11:42 +0200 Message-Id: <20181209111142.2353-1-yuval.shaia@oracle.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9101 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=878 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1812090107 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Array iterator stays at the same slot, fix it. Fixes: 8700e3e7c485 ("Soft RoCE driver") Signed-off-by: Yuval Shaia Reviewed-by: Bart Van Assche --- v1 -> v2: * Add Fixes tag as suggested by Parav * Add Bart's r-b v2 -> v3: * Remove blank line after "Fixes" tag as pointed out by Leon --- drivers/infiniband/sw/rxe/rxe_pool.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/drivers/infiniband/sw/rxe/rxe_pool.c b/drivers/infiniband/sw/rxe/rxe_pool.c index 36b53fb94a49..bf662977258e 100644 --- a/drivers/infiniband/sw/rxe/rxe_pool.c +++ b/drivers/infiniband/sw/rxe/rxe_pool.c @@ -112,6 +112,18 @@ static inline struct kmem_cache *pool_cache(struct rxe_pool *pool) return rxe_type_info[pool->type].cache; } +static void rxe_cache_clean(size_t to_idx) +{ + int i; + struct rxe_type_info *type; + + for (i = 0; i < to_idx; i++) { + type = &rxe_type_info[i]; + kmem_cache_destroy(type->cache); + type->cache = NULL; + } +} + int rxe_cache_init(void) { int err; @@ -136,24 +148,14 @@ int rxe_cache_init(void) return 0; err1: - while (--i >= 0) { - kmem_cache_destroy(type->cache); - type->cache = NULL; - } + rxe_cache_clean(--i); return err; } void rxe_cache_exit(void) { - int i; - struct rxe_type_info *type; - - for (i = 0; i < RXE_NUM_TYPES; i++) { - type = &rxe_type_info[i]; - kmem_cache_destroy(type->cache); - type->cache = NULL; - } + rxe_cache_clean(RXE_NUM_TYPES); } static int rxe_pool_init_index(struct rxe_pool *pool, u32 max, u32 min)