From patchwork Mon Jan 14 08:44:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 10761747 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 326FF6C5 for ; Mon, 14 Jan 2019 08:47:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2428228B8D for ; Mon, 14 Jan 2019 08:47:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1682428BA0; Mon, 14 Jan 2019 08:47:44 +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.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 C216F28B8D for ; Mon, 14 Jan 2019 08:47:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4EF06E5F0; Mon, 14 Jan 2019 08:47:42 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3B40D6E5F0 for ; Mon, 14 Jan 2019 08:47:41 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id f188so7902790wmf.5 for ; Mon, 14 Jan 2019 00:47:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2eE37dROlTulgp8EehVvJi2luqnF0TACq6kEzJmTxMk=; b=Q5Pm+0UP7QaCQkbEUUKvAjIvZVHowUOVRY1E00BVNd2e/4BRU+8DJjzpFU0pDbm27b 7ZHdIugVnIb1eqpH6NFF8FLhTAx458n5QRCvGdFFWZ5mMiuYkjwH/eIPUN3CI62HQKzX tLuQr2hlSS0djE6MQ+G80zRVNG7I2UNpge599qkU26qcLJiAtE+xs8tAh7d4biwRotA/ qw3Mnb5BO0V46rVhD6ASrOy2co5izP8BWt6nOK/aEWo/cNTKwEwzMCljTVhrIXwWJiOc RbFo1pmyWjvSIDao33Ch0qNxeKAWoEAFjh0/OpzFynBIkbamlB0lIHjCGAHiEoeRLxGv W0Ew== X-Gm-Message-State: AJcUukeOAJ3glvntQ0MREp0qiDL3CKi5rdhLRUHM5j/U77nOZm2maPFi I5+okzYGHi2rG92XVvGCEuNyI8tb X-Google-Smtp-Source: ALg8bN5RKon5LG+YhMaJpZ6ZGIcZAYHcE49nctbMpE/RT06R4wcLAO8Vo0eeEWo4EmJSZIN/jX6H7g== X-Received: by 2002:a1c:6489:: with SMTP id y131mr10811529wmb.34.1547455659653; Mon, 14 Jan 2019 00:47:39 -0800 (PST) Received: from localhost.localdomain (cpc91192-cmbg18-2-0-cust374.5-4.cable.virginm.net. [80.6.113.119]) by smtp.gmail.com with ESMTPSA id 60sm100671845wrb.81.2019.01.14.00.47.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Jan 2019 00:47:39 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Subject: [PATCH 1/2] drm: factor out drm_close_helper() function Date: Mon, 14 Jan 2019 08:44:09 +0000 Message-Id: <20190114084410.15266-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 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: , Cc: emil.l.velikov@gmail.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Will be used to plug an existing memory leak. Signed-off-by: Emil Velikov --- drivers/gpu/drm/drm_file.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c index ffa8dc35515f..149506a20bdc 100644 --- a/drivers/gpu/drm/drm_file.c +++ b/drivers/gpu/drm/drm_file.c @@ -262,6 +262,18 @@ void drm_file_free(struct drm_file *file) kfree(file); } +static void drm_close_helper(struct file *filp) +{ + struct drm_file *file_priv = filp->private_data; + struct drm_device *dev = file_priv->minor->dev; + + mutex_lock(&dev->filelist_mutex); + list_del(&file_priv->lhead); + mutex_unlock(&dev->filelist_mutex); + + drm_file_free(file_priv); +} + static int drm_setup(struct drm_device * dev) { int ret; @@ -473,11 +485,7 @@ int drm_release(struct inode *inode, struct file *filp) DRM_DEBUG("open_count = %d\n", dev->open_count); - mutex_lock(&dev->filelist_mutex); - list_del(&file_priv->lhead); - mutex_unlock(&dev->filelist_mutex); - - drm_file_free(file_priv); + drm_close_helper(filp); if (!--dev->open_count) { drm_lastclose(dev);