From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F9F21DF743; Tue, 8 Oct 2024 12:21:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390110; cv=none; b=X0RUp1WskQXiZnvmlSNUu5RtXoBhausPtPIvdseQJStHhev8WE8SYGemXhDuwHMkSWnDoiIMsD24Fk7XqUqCN6xHO2lgdZ/D1gv346/p3UR1YQXg2Btl8XLxk6zRcNKCuzDGyvfax7qOj3YtLU8oFapqabesC+hXwouo7SXK1lM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728390110; c=relaxed/simple; bh=c+824C39pUhXU53j6wLG9XmFkvBBITtQ9//P+AV1m2c=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E8gGnm2i2YTyR/eA9CRJ8ySKuPfFKj/pkwLbPmaSGeQITpjzosRxLYGW7ec4FrRVSkxxgVi5YaN+SiCOxEEGDJZvhIZvLsOhBo9GBkGa7hujjrCtUUGZYr3PFW0YIDTdK3V6t/khZ1I8HuSRaPgsx/qB107sHdoRpyIdi5TeVnE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=lA7xVNST; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="lA7xVNST" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2B1AC4CECC; Tue, 8 Oct 2024 12:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1728390110; bh=c+824C39pUhXU53j6wLG9XmFkvBBITtQ9//P+AV1m2c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lA7xVNSTzS+FE0BrxA8vUhy3t+JpaxF25pbURtvZzi2sjjCVoMrB6JK5opS6lMl0Y 8L+oV4r6x3FeITUMNGAQ7ywhrpx0mc8kIKxsw08tsv//enZXv/+Q8DaBylgtbwt4OX 2jWAdeNgQqa00k7g0mhB/74fqoMDaU188AMlxGbo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Helge Deller , Sasha Levin Subject: [PATCH 6.10 162/482] fbdev: efifb: Register sysfs groups through driver core Date: Tue, 8 Oct 2024 14:03:45 +0200 Message-ID: <20241008115654.680859271@linuxfoundation.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241008115648.280954295@linuxfoundation.org> References: <20241008115648.280954295@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thomas Weißschuh [ Upstream commit 95cdd538e0e5677efbdf8aade04ec098ab98f457 ] The driver core can register and cleanup sysfs groups already. Make use of that functionality to simplify the error handling and cleanup. Also avoid a UAF race during unregistering where the sysctl attributes were usable after the info struct was freed. Signed-off-by: Thomas Weißschuh Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/efifb.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index 8dd82afb3452b..595b8e27bea66 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -561,15 +561,10 @@ static int efifb_probe(struct platform_device *dev) break; } - err = sysfs_create_groups(&dev->dev.kobj, efifb_groups); - if (err) { - pr_err("efifb: cannot add sysfs attrs\n"); - goto err_unmap; - } err = fb_alloc_cmap(&info->cmap, 256, 0); if (err < 0) { pr_err("efifb: cannot allocate colormap\n"); - goto err_groups; + goto err_unmap; } err = devm_aperture_acquire_for_platform_device(dev, par->base, par->size); @@ -587,8 +582,6 @@ static int efifb_probe(struct platform_device *dev) err_fb_dealloc_cmap: fb_dealloc_cmap(&info->cmap); -err_groups: - sysfs_remove_groups(&dev->dev.kobj, efifb_groups); err_unmap: if (mem_flags & (EFI_MEMORY_UC | EFI_MEMORY_WC)) iounmap(info->screen_base); @@ -608,12 +601,12 @@ static void efifb_remove(struct platform_device *pdev) /* efifb_destroy takes care of info cleanup */ unregister_framebuffer(info); - sysfs_remove_groups(&pdev->dev.kobj, efifb_groups); } static struct platform_driver efifb_driver = { .driver = { .name = "efi-framebuffer", + .dev_groups = efifb_groups, }, .probe = efifb_probe, .remove_new = efifb_remove, -- 2.43.0