From patchwork Thu Feb 27 18:14:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 11409251 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7F9F71580 for ; Thu, 27 Feb 2020 18:16:37 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5ECE7246B2 for ; Thu, 27 Feb 2020 18:16:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=ffwll.ch header.i=@ffwll.ch header.b="XlccQy4C" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5ECE7246B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DAB66ECF2; Thu, 27 Feb 2020 18:16:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wr1-x444.google.com (mail-wr1-x444.google.com [IPv6:2a00:1450:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 919256ECE1 for ; Thu, 27 Feb 2020 18:15:42 +0000 (UTC) Received: by mail-wr1-x444.google.com with SMTP id v4so4612830wrs.8 for ; Thu, 27 Feb 2020 10:15:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=q7MWd5yKDDN4kYPLlNzre71uaGPyUp7BlB0OXWxic1I=; b=XlccQy4CusVfgttdkI0YhmczWKi4xlIw0+IB7MXB+GER63yF9RA4HC/1AqX9AtvCi8 jQO3TPEU7ptqXfOPoaC6BM+wk7whLqNOg2xboIJXDU4VgyxiosQQzhfk8G2u+u2wtdTv vPKLFTV95dzO0iSA2k79RhI6ZINEFCew4gWVM= 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=q7MWd5yKDDN4kYPLlNzre71uaGPyUp7BlB0OXWxic1I=; b=VcZky2NydnRh1PNDn18lf6+hn9/10zRj1zpKlhfn+eKLs+42KfvNIyVPazIuvwjOph DojzrbsUbnEF0lVEvHTfaHlR+pZRQI2BUlkYR8a0U6xU6QPDRgOR8uvr51+jpmsJZp+k JQva8L+V+2K1ipZ9tI+xFf8IqLSos2ETm7Yg88vECxaGXh/F49zCKTCcIb5v+eFASkA4 dTk2frlo3SWTf0Kikn8Omak2XApQE5Lo9S9dOFo6zxrq3+PU8v3A9AwAOTNGyXD3uPZN K+T+QcBR0JbSB91cVBaRBV/q49+7iSFgvsOWChTqS51xIPBViYjxY1zeZo2ohDPrqEtI 9Lyg== X-Gm-Message-State: APjAAAWNhTvUW5rU6rgJBRfOyUuTRk83WGAP9IIum1lxQK5F4g3ypFtl XVF6UMkRn39e2L0DievLYnRA2duibBA= X-Google-Smtp-Source: APXvYqxKlhtL3qzUiHRxm/EJhFR/2F8qOw7JJt6Mi3qILMY407qslPkxhzFMsX6GhxXifZZRR0otkw== X-Received: by 2002:adf:e383:: with SMTP id e3mr163819wrm.10.1582827340841; Thu, 27 Feb 2020 10:15:40 -0800 (PST) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id q1sm8551152wrw.5.2020.02.27.10.15.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 10:15:40 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 09/51] drm/cirrus: Use drmm_add_final_kfree Date: Thu, 27 Feb 2020 19:14:40 +0100 Message-Id: <20200227181522.2711142-10-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200227181522.2711142-1-daniel.vetter@ffwll.ch> References: <20200227181522.2711142-1-daniel.vetter@ffwll.ch> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Daniel Vetter , Intel Graphics Development , m.felsch@pengutronix.de, virtualization@lists.linux-foundation.org, Gerd Hoffmann , Thomas Zimmermann , Dave Airlie , Daniel Vetter , Sam Ravnborg Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" With this we can drop the final kfree from the release function. I also noticed that cirrus forgot to call drm_dev_fini(). v2: Don't call kfree(cirrus) after we've handed overship of that to drm_device and the drmm_ stuff. Signed-off-by: Daniel Vetter Cc: Dave Airlie Cc: Gerd Hoffmann Cc: Daniel Vetter Cc: "Noralf Trønnes" Cc: Linus Walleij Cc: Sam Ravnborg Cc: Thomas Zimmermann Cc: virtualization@lists.linux-foundation.org Acked-by: Sam Ravnborg --- drivers/gpu/drm/cirrus/cirrus.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/cirrus/cirrus.c b/drivers/gpu/drm/cirrus/cirrus.c index d2ff63ce8eaf..2232556ce34c 100644 --- a/drivers/gpu/drm/cirrus/cirrus.c +++ b/drivers/gpu/drm/cirrus/cirrus.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -527,10 +528,8 @@ static void cirrus_mode_config_init(struct cirrus_device *cirrus) static void cirrus_release(struct drm_device *dev) { - struct cirrus_device *cirrus = dev->dev_private; - drm_mode_config_cleanup(dev); - kfree(cirrus); + drm_dev_fini(dev); } DEFINE_DRM_GEM_FOPS(cirrus_fops); @@ -575,9 +574,12 @@ static int cirrus_pci_probe(struct pci_dev *pdev, dev = &cirrus->dev; ret = drm_dev_init(dev, &cirrus_driver, &pdev->dev); - if (ret) - goto err_free_cirrus; + if (ret) { + kfree(cirrus); + goto err_pci_release; + } dev->dev_private = cirrus; + drmm_add_final_kfree(dev, cirrus); ret = -ENOMEM; cirrus->vram = ioremap(pci_resource_start(pdev, 0), @@ -618,8 +620,6 @@ static int cirrus_pci_probe(struct pci_dev *pdev, iounmap(cirrus->vram); err_dev_put: drm_dev_put(dev); -err_free_cirrus: - kfree(cirrus); err_pci_release: pci_release_regions(pdev); return ret;