Skip to contentSkip to conversation

drm/dsi: Do the 'msg' check prior to dereferencing it.

PATCH In review Fabio Estevam 2 participants 2 messages Dec 17, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/dsi: Do the 'msg' check prior to dereferencing it.

From: Fabio Estevam <[email protected]>

Commit a52879e8d7cb ("drm/dsi: Add message to packet translator") caused the following Smatch complaint:

drivers/gpu/drm/drm_mipi_dsi.c:328 mipi_dsi_create_packet()
warn: variable dereferenced before check 'msg' (see line 326)

Do the 'msg' check prior to dereferencing it.

---
 drivers/gpu/drm/drm_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/drm_mipi_dsi.c +3 -1
index c0644bb..a9812db 100644
@@ -323,11 +323,13 @@ EXPORT_SYMBOL(mipi_dsi_packet_format_is_long);
 int mipi_dsi_create_packet(struct mipi_dsi_packet *packet,
 			   const struct mipi_dsi_msg *msg)
 {
-	const u8 *tx = msg->tx_buf;
+	const u8 *tx;
 
 	if (!packet || !msg)
 		return -EINVAL;
 
+	tx = msg->tx_buf;
+
 	/* do some minimum sanity checking */
 	if (!mipi_dsi_packet_format_is_short(msg->type) &&
 	    !mipi_dsi_packet_format_is_long(msg->type))
Signature · 6 lines
1.9.1

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw
Quoted 8 lines · Fabio Estevam

From: Fabio Estevam <[email protected]>

Commit a52879e8d7cb ("drm/dsi: Add message to packet translator") caused the following Smatch complaint:

drivers/gpu/drm/drm_mipi_dsi.c:328 mipi_dsi_create_packet()
warn: variable dereferenced before check 'msg' (see line 326)

Quoted 7 lines

Do the 'msg' check prior to dereferencing it.

---
 drivers/gpu/drm/drm_mipi_dsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

I've had an equivalent patch in the drm/panel tree for almost two weeks but had forgotten to push. Pushed now.

Thierry

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel