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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D390AC433F5 for ; Mon, 10 Oct 2022 00:18:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232222AbiJJASc (ORCPT ); Sun, 9 Oct 2022 20:18:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231754AbiJJARx (ORCPT ); Sun, 9 Oct 2022 20:17:53 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 96CD85E565; Sun, 9 Oct 2022 16:53:08 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83B0C60D57; Sun, 9 Oct 2022 23:53:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99AA1C43142; Sun, 9 Oct 2022 23:53:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665359586; bh=E8lnajgY5yjgmA9Ze197EDHKNzbkkiNgzzOdflXRywI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=siaFa+E9z32rgaYY1oorFeDSqNnzMRHxwELXjayX4vzG99RlHbqMg5UeiZfJ18b1x tzoyMsHmvKkh0+KmdTKdon2/r/qm6PIXqrp9wXYL5kXkIKqYZAH2Sx7YkMVDqJHNTP nYhzmX99d2aauIHfkfemARhbdCI7ZxGxpQrMJpIL7laTIpQ+L5TbALbklx6yw7QgrL k/r1KR2HrFS05AxYfWrM6fWri4Psk8Fn9qV0sS6V4VeZg7/aG8iR/SUzy8V3B/hsZZ MPK7sKWFgFRDK9WmoU8XJ7K0WhrJvwDfLGJF/pg+q0JTPuw1BzBVt2Omt0d/lttrxe vp/B51ZywuqPg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Simon Ser , Daniel Vetter , =?UTF-8?q?Ville=20Syrj=C3=A4l=C3=A4?= , Jani Nikula , Lyude Paul , Sasha Levin , maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@gmail.com, daniel@ffwll.ch, dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.19 13/36] drm: hide unregistered connectors from GETCONNECTOR IOCTL Date: Sun, 9 Oct 2022 19:51:59 -0400 Message-Id: <20221009235222.1230786-13-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221009235222.1230786-1-sashal@kernel.org> References: <20221009235222.1230786-1-sashal@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Simon Ser [ Upstream commit 981f09295687f856d5345e19c7084aca481c1395 ] When registering a connector, the kernel sends a hotplug uevent in drm_connector_register(). When unregistering a connector, drivers are expected to send a uevent as well. However, user-space has no way to figure out that the connector isn't registered anymore: it'll still be reported in GETCONNECTOR IOCTLs. The documentation for DRM_CONNECTOR_UNREGISTERED states: > The connector […] has since been unregistered and removed from > userspace, or the connector was unregistered before it had a chance > to be exposed to userspace Signed-off-by: Simon Ser Cc: Daniel Vetter Cc: Ville Syrjälä Cc: Jani Nikula Reviewed-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20220801133754.461037-1-contact@emersion.fr Signed-off-by: Sasha Levin --- drivers/gpu/drm/drm_mode_config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/drm_mode_config.c b/drivers/gpu/drm/drm_mode_config.c index 37b4b9f0e468..6a326b41d193 100644 --- a/drivers/gpu/drm/drm_mode_config.c +++ b/drivers/gpu/drm/drm_mode_config.c @@ -150,6 +150,9 @@ int drm_mode_getresources(struct drm_device *dev, void *data, count = 0; connector_id = u64_to_user_ptr(card_res->connector_id_ptr); drm_for_each_connector_iter(connector, &conn_iter) { + if (connector->registration_state != DRM_CONNECTOR_REGISTERED) + continue; + /* only expose writeback connectors if userspace understands them */ if (!file_priv->writeback_connectors && (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK)) -- 2.35.1