All of lore.kernel.org
 help / color / mirror / Atom feed
From: Brian Norris <briannorris@chromium.org>
To: "Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@linux.ie>,
	"Heiko Stübner" <heiko@sntech.de>
Cc: dri-devel@lists.freedesktop.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	Sandy Huang <hjc@rock-chips.com>,
	Doug Anderson <dianders@chromium.org>,
	Sean Paul <seanpaul@chromium.org>,
	Brian Norris <briannorris@chromium.org>
Subject: [PATCH] drm/rockchip: vop: Don't crash for invalid duplicate_state()
Date: Fri, 17 Jun 2022 17:26:52 -0700	[thread overview]
Message-ID: <20220617172623.1.I62db228170b1559ada60b8d3e1637e1688424926@changeid> (raw)

It's possible for users to try to duplicate the CRTC state even when the
state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other
users of __drm_atomic_helper_crtc_duplicate_state()) already guard this
with a WARN_ON() instead of crashing, so let's do that here too.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 74562d40f639..daf192881353 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1570,6 +1570,9 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc)
 {
 	struct rockchip_crtc_state *rockchip_state;
 
+	if (WARN_ON(!crtc->state))
+		return NULL;
+
 	rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL);
 	if (!rockchip_state)
 		return NULL;
-- 
2.36.1.476.g0c4daa206d-goog


WARNING: multiple messages have this Message-ID (diff)
From: Brian Norris <briannorris@chromium.org>
To: "Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@linux.ie>,
	"Heiko Stübner" <heiko@sntech.de>
Cc: Brian Norris <briannorris@chromium.org>,
	Doug Anderson <dianders@chromium.org>,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	Sandy Huang <hjc@rock-chips.com>,
	Sean Paul <seanpaul@chromium.org>
Subject: [PATCH] drm/rockchip: vop: Don't crash for invalid duplicate_state()
Date: Fri, 17 Jun 2022 17:26:52 -0700	[thread overview]
Message-ID: <20220617172623.1.I62db228170b1559ada60b8d3e1637e1688424926@changeid> (raw)

It's possible for users to try to duplicate the CRTC state even when the
state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other
users of __drm_atomic_helper_crtc_duplicate_state()) already guard this
with a WARN_ON() instead of crashing, so let's do that here too.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 74562d40f639..daf192881353 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1570,6 +1570,9 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc)
 {
 	struct rockchip_crtc_state *rockchip_state;
 
+	if (WARN_ON(!crtc->state))
+		return NULL;
+
 	rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL);
 	if (!rockchip_state)
 		return NULL;
-- 
2.36.1.476.g0c4daa206d-goog


WARNING: multiple messages have this Message-ID (diff)
From: Brian Norris <briannorris@chromium.org>
To: "Daniel Vetter" <daniel@ffwll.ch>,
	"David Airlie" <airlied@linux.ie>,
	"Heiko Stübner" <heiko@sntech.de>
Cc: dri-devel@lists.freedesktop.org,
	linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
	Sandy Huang <hjc@rock-chips.com>,
	Doug Anderson <dianders@chromium.org>,
	Sean Paul <seanpaul@chromium.org>,
	Brian Norris <briannorris@chromium.org>
Subject: [PATCH] drm/rockchip: vop: Don't crash for invalid duplicate_state()
Date: Fri, 17 Jun 2022 17:26:52 -0700	[thread overview]
Message-ID: <20220617172623.1.I62db228170b1559ada60b8d3e1637e1688424926@changeid> (raw)

It's possible for users to try to duplicate the CRTC state even when the
state doesn't exist. drm_atomic_helper_crtc_duplicate_state() (and other
users of __drm_atomic_helper_crtc_duplicate_state()) already guard this
with a WARN_ON() instead of crashing, so let's do that here too.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---

 drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
index 74562d40f639..daf192881353 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
@@ -1570,6 +1570,9 @@ static struct drm_crtc_state *vop_crtc_duplicate_state(struct drm_crtc *crtc)
 {
 	struct rockchip_crtc_state *rockchip_state;
 
+	if (WARN_ON(!crtc->state))
+		return NULL;
+
 	rockchip_state = kzalloc(sizeof(*rockchip_state), GFP_KERNEL);
 	if (!rockchip_state)
 		return NULL;
-- 
2.36.1.476.g0c4daa206d-goog


_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

             reply	other threads:[~2022-06-18  0:27 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-18  0:26 Brian Norris [this message]
2022-06-18  0:26 ` [PATCH] drm/rockchip: vop: Don't crash for invalid duplicate_state() Brian Norris
2022-06-18  0:26 ` Brian Norris
2022-06-23 16:46 ` Sean Paul
2022-06-23 16:46   ` Sean Paul
2022-06-23 16:46   ` Sean Paul
2022-06-23 23:44 ` Doug Anderson
2022-06-23 23:44   ` Doug Anderson
2022-06-23 23:44   ` Doug Anderson
2022-06-24  7:23   ` Heiko Stuebner
2022-06-24  7:23     ` Heiko Stuebner
2022-06-24  7:23     ` Heiko Stuebner
2022-06-24 17:57     ` Brian Norris
2022-06-24 17:57       ` Brian Norris
2022-06-24 17:57       ` Brian Norris
2022-06-24 20:37       ` Heiko Stuebner
2022-06-24 20:37         ` Heiko Stuebner
2022-06-24 20:37         ` Heiko Stuebner
2022-07-03 11:11 ` Heiko Stuebner
2022-07-03 11:11   ` Heiko Stuebner
2022-07-03 11:11   ` Heiko Stuebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220617172623.1.I62db228170b1559ada60b8d3e1637e1688424926@changeid \
    --to=briannorris@chromium.org \
    --cc=airlied@linux.ie \
    --cc=daniel@ffwll.ch \
    --cc=dianders@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=heiko@sntech.de \
    --cc=hjc@rock-chips.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=seanpaul@chromium.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.