From patchwork Fri May 18 17:00:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Vesely X-Patchwork-Id: 10411563 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1A562602C2 for ; Fri, 18 May 2018 17:00:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0AC0328A00 for ; Fri, 18 May 2018 17:00:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F353728A0D; Fri, 18 May 2018 17:00:20 +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=-5.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AEE7228A00 for ; Fri, 18 May 2018 17:00:20 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id DA3A76EE82; Fri, 18 May 2018 17:00:17 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-qt0-x242.google.com (mail-qt0-x242.google.com [IPv6:2607:f8b0:400d:c0d::242]) by gabe.freedesktop.org (Postfix) with ESMTPS id DB8666EE80 for ; Fri, 18 May 2018 17:00:13 +0000 (UTC) Received: by mail-qt0-x242.google.com with SMTP id f5-v6so11143251qth.2 for ; Fri, 18 May 2018 10:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=scarletmail-rutgers-edu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=t/PLtWObrFtcmyS+1eltXpKUh7h4PuQSUComUV3bYqM=; b=rf/YBwdOxpP5UpOWndSFS57PxCGLf4krvey+VUuetW3mHh5tVfL1KhiasYetr+lKQ1 RVjrTjctAgNh5H20KWLobOnGr8HFAZYvLFHUKWVHpIYuNHa551Lva+dBiUZRG3Vn4kGt yZxbRWj+NehGYWEgN9VG+uP0usxQYkvB1Bujg5ENGyNpFBRZxVzsNt3X6XAiZwmLr3ld 4q/L9adaFi5zZ8L79W4JrZQgAB8scWIUy1Y4dueQrt5Hj8uPa0leVhtD1pQyO5FVOCeQ aj+cheZ4yzMQ2vln/oy0Cx9EwKHFYbgLvnOvY+qNbyX6Dav/3TlFOJk+tc45er6Lb7Ch o2Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=t/PLtWObrFtcmyS+1eltXpKUh7h4PuQSUComUV3bYqM=; b=Kz35ypuPTzW9IPoiaKIBulJi/8rZlIKcuhDZzx6qkPAlJyYT3AelXqrspwaPIximyu V/538uMy+jdexBExDplfpNKWS6qZV2bTliTnJ85Z5gMVjQ36Dyj24WHFS1G/gtYjU8Mq cxFyh50voWy0WVbr686TyADOCS1Ws3pBekUk6meroFgItsYlba+w4EWnmnV+bN0dY3Gb NYBF48zzQ2P7dybNh8dTVibH97k2GRVjRYpZ1IzmcQFOP/Fj5cBmllx78iX+bn5gXFsw zHMX/L4d4/kihO2dZwetRlxpDDpRBfdQDjaPCS2Dcb1WRPL3uvvb3tDKUoffV0zyWjJe ovlg== X-Gm-Message-State: ALKqPwcYcg/P3ygVVqmKcN1/jam7T6lF7UbiqxRlXOldQ8FZ4G8K4dfs VAtqZU6GCyBlYeS2g5woq/xxlGa3hj8= X-Google-Smtp-Source: AB8JxZpvAi76Hmcbu/zVZ8ftS4aIoj+Tx68DV2S/r1i8+Uc7SWCOeNp0rL3niKz07eVICpoQa31LsQ== X-Received: by 2002:ac8:235c:: with SMTP id b28-v6mr9882713qtb.212.1526662812808; Fri, 18 May 2018 10:00:12 -0700 (PDT) Received: from adriatix.rutgers.edu (pool-128-6-37-254.nat.rutgers.edu. [128.6.37.254]) by smtp.gmail.com with ESMTPSA id b27-v6sm5969152qtc.66.2018.05.18.10.00.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 10:00:11 -0700 (PDT) From: Jan Vesely To: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH libdrm 3/3] amdgpu: Destroy fd_hash table when the last device is removed. Date: Fri, 18 May 2018 13:00:07 -0400 Message-Id: <20180518170007.2847-3-jan.vesely@rutgers.edu> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518170007.2847-1-jan.vesely@rutgers.edu> References: <20180518170007.2847-1-jan.vesely@rutgers.edu> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Fixes memory leak on module unload. Analogous to mesa commit of the same name. Signed-off-by: Jan Vesely --- amdgpu/amdgpu_device.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c index e23dd3b3..34ac95b8 100644 --- a/amdgpu/amdgpu_device.c +++ b/amdgpu/amdgpu_device.c @@ -128,6 +128,10 @@ static void amdgpu_device_free_internal(amdgpu_device_handle dev) { pthread_mutex_lock(&fd_mutex); util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd)); + if (util_hash_table_count(fd_tab) == 0) { + util_hash_table_destroy(fd_tab); + fd_tab = NULL; + } close(dev->fd); if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd)) close(dev->flink_fd);