Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1020551yba; Thu, 4 Apr 2019 02:35:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqyfcuun+Mwk5Tk98fYoUpGn2KVtwrnhepJliGvSrWSKHhnAOJhzhVw3327WvqeQGgGhDqZ5 X-Received: by 2002:a62:14c3:: with SMTP id 186mr4862716pfu.21.1554370529049; Thu, 04 Apr 2019 02:35:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554370529; cv=none; d=google.com; s=arc-20160816; b=BjDr45lAgHDHvUc+ageXKQmA892oWCSQQ8TFlc5gwsOgG1oyrFsalIC5ctf5Jf8kHu sqhWTUoMtgUE7+i7H8t3BiL1NkxEOVebZ7sCLfDt7jnpTbcPkdYkUnobAZTyYHLzr7JR OLcI6AKZXHuFXnF6qYR2F0iCBfv2im5wonam41GqQ34vw1sRItmUwCJDAAoCtwh2XraS kELmRshg3Z1x+oen4rv5m8bjtVUaSuv7wkmNoWB798ByiFtO0RSiB78k1p4CGch9GHwW HTGkS7upNxtOGsDcz7YB3vtNxypR1UDEvwnRyPu5dywqFzeCkNeYfAsSqSBiHlXAlh/u 958g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=b12o9022Rc9qcCja/7c7BDHpT8b1auJEIpkzzO16gEI=; b=itRlfwyxKqq9REMHSActpQrTh0K5JXOlsiqJtWeQyPuFebWn/OXJLVrSEpNlWfJHjw SWMYJip8hQXmj0a1bj4/rwjg/TSn12Og3hpJ7wy98uXzW/col3yQn1gjZIdxY+TXzT49 lYfD69KSiCM4LgC1i9be0ogyG1bUxHzaDCfg+4dkNPU2OuhDN/tefPA62vIZpZKxx8UM lE26//lK4naX+yU3Ndy2ze3PdyJsU5r0M3iNN1qGxyuS4PSFHK6AJBUGRwHhG1wnY+p/ FQwCDmCXL8U4s0X9roJq/A9bUUW/m3YRLh2AYcvn/P7wfmoHWts2dW2mYo8b5myB0Xa9 602w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U824lTLr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si15903529pfa.153.2019.04.04.02.35.14; Thu, 04 Apr 2019 02:35:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=U824lTLr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732548AbfDDJHm (ORCPT + 99 others); Thu, 4 Apr 2019 05:07:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:46472 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732540AbfDDJHj (ORCPT ); Thu, 4 Apr 2019 05:07:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 298152183E; Thu, 4 Apr 2019 09:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554368858; bh=Cx7jOCh8ess6DevXuXn1Dlc5qQY4VUuQwTRL9Ex2y/E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=U824lTLrYcdlpD0wmF0fcZC7ZVCu+Q+JdYNRfJQ6Y3s2ODyAjQSPeEgU0E/PUlRK1 e9/53Mms1srm0CtUe/u5ss+wNX4PeAMx3NVAUSLssm+LCx33Fa4s/W9cLPhzPsiKpL USuM29oNZ9EX+jYM3KXp9SwwLLH/WMr/eUldLvTc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , Peter Wu , Sasha Levin Subject: [PATCH 4.19 178/187] drm/fb-helper: fix leaks in error path of drm_fb_helper_fbdev_setup Date: Thu, 4 Apr 2019 10:48:35 +0200 Message-Id: <20190404084611.512091356@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190404084603.119654039@linuxfoundation.org> References: <20190404084603.119654039@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 00eb5b0da8d27b3c944bfc959c3344d665caae26 ] After drm_fb_helper_fbdev_setup calls drm_fb_helper_init, "dev->fb_helper" will be initialized (and thus drm_fb_helper_fini will have some effect). After that, drm_fb_helper_initial_config is called which may call the "fb_probe" driver callback. This driver callback may call drm_fb_helper_defio_init (as is done by drm_fb_helper_generic_probe) or set a framebuffer (as is done by bochs) as documented. These are normally cleaned up on exit by drm_fb_helper_fbdev_teardown which also calls drm_fb_helper_fini. If an error occurs after "fb_probe", but before setup is complete, then calling just drm_fb_helper_fini will leak resources. This was triggered by df2052cc922 ("bochs: convert to drm_fb_helper_fbdev_setup/teardown"): [ 50.008030] bochsdrmfb: enable CONFIG_FB_LITTLE_ENDIAN to support this framebuffer [ 50.009436] bochs-drm 0000:00:02.0: [drm:drm_fb_helper_fbdev_setup] *ERROR* fbdev: Failed to set configuration (ret=-38) [ 50.011456] [drm] Initialized bochs-drm 1.0.0 20130925 for 0000:00:02.0 on minor 2 [ 50.013604] WARNING: CPU: 1 PID: 1 at drivers/gpu/drm/drm_mode_config.c:477 drm_mode_config_cleanup+0x280/0x2a0 [ 50.016175] CPU: 1 PID: 1 Comm: swapper/0 Tainted: G T 4.20.0-rc7 #1 [ 50.017732] EIP: drm_mode_config_cleanup+0x280/0x2a0 ... [ 50.023155] Call Trace: [ 50.023155] ? bochs_kms_fini+0x1e/0x30 [ 50.023155] ? bochs_unload+0x18/0x40 This can be reproduced with QEMU and CONFIG_FB_LITTLE_ENDIAN=n. Link: https://lkml.kernel.org/r/20181221083226.GI23332@shao2-debian Link: https://lkml.kernel.org/r/20181223004315.GA11455@al Fixes: 8741216396b2 ("drm/fb-helper: Add drm_fb_helper_fbdev_setup/teardown()") Reported-by: kernel test robot Cc: Noralf Trønnes Signed-off-by: Peter Wu Reviewed-by: Noralf Trønnes Signed-off-by: Noralf Trønnes Link: https://patchwork.freedesktop.org/patch/msgid/20181223005507.28328-1-peter@lekensteyn.nl Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_fb_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index e65596617239..a0663f44e218 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -2877,7 +2877,7 @@ int drm_fb_helper_fbdev_setup(struct drm_device *dev, return 0; err_drm_fb_helper_fini: - drm_fb_helper_fini(fb_helper); + drm_fb_helper_fbdev_teardown(dev); return ret; } -- 2.19.1