From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C69E2C11D3D for ; Thu, 27 Feb 2020 18:15:46 +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 A2A962469B for ; Thu, 27 Feb 2020 18:15:46 +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="iuZKAXQh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A2A962469B 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 9817C6EC47; Thu, 27 Feb 2020 18:15:38 +0000 (UTC) Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by gabe.freedesktop.org (Postfix) with ESMTPS id 686D26EACD for ; Thu, 27 Feb 2020 18:15:36 +0000 (UTC) Received: by mail-wm1-x344.google.com with SMTP id f15so421396wml.3 for ; Thu, 27 Feb 2020 10:15:36 -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=jyV7bNjLu1SQ7vKcBd294xD9HrCo7tzU5S6Usg9xWsM=; b=iuZKAXQhruuVsFLUktBVg7py+mMqJxsH6IWepRR2Qdsx+kSrzXeemepz+H1XbKBw71 m7tZxW+SYKH+XWKDS6BzHZuIfcD3nYPcadw6X+2eqfcGwk0WFWIMA5DuBuxHBtYEq88J pIg952ThHq0ILPYGTY9qbGh/U9uPXXw7tRTaE= 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=jyV7bNjLu1SQ7vKcBd294xD9HrCo7tzU5S6Usg9xWsM=; b=p8FnN54ENiJo86XvpQ2lXhDhkadgz9+/gkx+Ujr4Hh2HURkfAh3en8w52LXexXPc35 jQuniIU+wUSatZcNv2ZDC9Mub/pY7Ha8bpUX5Z5QIIJL3NEWwehg3e/qNRGfMtqAfaej oDuwEChs16hTI71zbm4jrC4OHTfiSsWtSS5wMjtophImJ3f+sJEFjYsnuQrnmnJsiCrt RJfyUZ12Pn22p6QzwQPylJZ7KU7vAb0BkrV1mhc7ilnqMQSKNJDXT5n1i+WIhkt60OxD h3WYq9AHPThhqMTOLWYVhvAqNYL6fKbAZJXMU00fomUisKTOPMxAIMG5NVOi1JFvBq0a yOEg== X-Gm-Message-State: APjAAAU8vOhGXLx3HczzM8GIGKPeo2GfKa48B8eBxisA55Ej4kwu6u2A eWno/405UKPnTQ51AADjBpURFLT8qxo= X-Google-Smtp-Source: APXvYqy1KGIqvDWaP9y/317NhLPsMTyJxxslCUMo+xlRnY58XN0X93cIaXfyPqnzF+0nskv3/XteqA== X-Received: by 2002:a1c:25c6:: with SMTP id l189mr49006wml.104.1582827333846; Thu, 27 Feb 2020 10:15:33 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2020 10:15:33 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 04/51] drm: Set final_kfree in drm_dev_alloc Date: Thu, 27 Feb 2020 19:14:35 +0100 Message-Id: <20200227181522.2711142-5-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: Oleksandr Andrushchenko , David Airlie , Daniel Vetter , Intel Graphics Development , m.felsch@pengutronix.de, Gerd Hoffmann , Thomas Zimmermann , Daniel Vetter , xen-devel@lists.xenproject.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" I also did a full review of all callers, and only the xen driver forgot to call drm_dev_put in the failure path. Fix that up too. v2: I noticed that xen has a drm_driver.release hook, and uses drm_dev_alloc(). We need to remove the kfree from xen_drm_drv_release(). bochs also has a release hook, but leaked the drm_device ever since commit 0a6659bdc5e8221da99eebb176fd9591435e38de Author: Gerd Hoffmann Date: Tue Dec 17 18:04:46 2013 +0100 drm/bochs: new driver This patch here fixes that leak. Same for virtio, started leaking with commit b1df3a2b24a917f8853d43fe9683c0e360d2c33a Author: Gerd Hoffmann Date: Tue Feb 11 14:58:04 2020 +0100 drm/virtio: add drm_driver.release callback. Cc: Gerd Hoffmann Cc: Oleksandr Andrushchenko Cc: xen-devel@lists.xenproject.org Reviewed-by: Oleksandr Andrushchenko Signed-off-by: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Thomas Zimmermann Cc: David Airlie Cc: Daniel Vetter Cc: Oleksandr Andrushchenko Cc: xen-devel@lists.xenproject.org --- drivers/gpu/drm/drm_drv.c | 3 +++ drivers/gpu/drm/xen/xen_drm_front.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 3e5627d6eba6..9e62e28bbc62 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -819,6 +820,8 @@ struct drm_device *drm_dev_alloc(struct drm_driver *driver, return ERR_PTR(ret); } + drmm_add_final_kfree(dev, dev); + return dev; } EXPORT_SYMBOL(drm_dev_alloc); diff --git a/drivers/gpu/drm/xen/xen_drm_front.c b/drivers/gpu/drm/xen/xen_drm_front.c index 4be49c1aef51..d22b5da38935 100644 --- a/drivers/gpu/drm/xen/xen_drm_front.c +++ b/drivers/gpu/drm/xen/xen_drm_front.c @@ -461,7 +461,6 @@ static void xen_drm_drv_release(struct drm_device *dev) drm_mode_config_cleanup(dev); drm_dev_fini(dev); - kfree(dev); if (front_info->cfg.be_alloc) xenbus_switch_state(front_info->xb_dev, @@ -561,6 +560,7 @@ static int xen_drm_drv_init(struct xen_drm_front_info *front_info) fail_modeset: drm_kms_helper_poll_fini(drm_dev); drm_mode_config_cleanup(drm_dev); + drm_dev_put(drm_dev); fail: kfree(drm_info); return ret; -- 2.24.1 _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel