Skip to contentSkip to conversation

staging: drm/imx: ipu-dc: signedness bug in ipu_dc_init_sync()

PATCH In review Dan Carpenter 3 participants 3 messages Aug 21, 2013

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

PATCH 1/1 staging: drm/imx: ipu-dc: signedness bug in ipu_dc_init_sync()

"map" needs to be signed for the error handling to work. In the success case then it holds a small non-negative value.

drivers/staging/imx-drm/ipu-v3/ipu-dc.c +3 -2
index 59f03f9..21bf1c8 100644
@@ -161,14 +161,15 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced,
 		u32 pixel_fmt, u32 width)
 {
 	struct ipu_dc_priv *priv = dc->priv;
-	u32 reg = 0, map;
+	u32 reg = 0;
+	int map;
 
 	dc->di = ipu_di_get_num(di);
 
 	map = ipu_pixfmt_to_map(pixel_fmt);
 	if (map < 0) {
 		dev_dbg(priv->dev, "IPU_DISP: No MAP\n");
-		return -EINVAL;
+		return map;
 	}
 
 	if (interlaced) {
Acked-by on v1 1/1
#1 lore raw

Dear Dan Carpenter,

Quoted 4 lines

"map" needs to be signed for the error handling to work. In the success case then it holds a small non-negative value.

Nice catch and quick glance over the source makes it seem right

Quoted 12 lines
(quoted diff) +0 -0

b/drivers/staging/imx-drm/ipu-v3/ipu-dc.c index 59f03f9..21bf1c8 100644

drivers/staging/imx-drm/ipu-v3/ipu-dc.c +2 -1
@@ -161,14 +161,15 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di
 *di, bool interlaced, u32 pixel_fmt, u32 width)
 {
 	struct ipu_dc_priv *priv = dc->priv;
-	u32 reg = 0, map;
+	u32 reg = 0;
+	int map;
 

drivers/staging/imx-drm/ipu-v3/ipu-dc.c int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di · line 175

Quoted 10 lines
drivers/staging/imx-drm/ipu-v3/ipu-dc.c +1 -1
 	dc->di = ipu_di_get_num(di);
 
 	map = ipu_pixfmt_to_map(pixel_fmt);
 	if (map < 0) {
 		dev_dbg(priv->dev, "IPU_DISP: No MAP\n");
-		return -EINVAL;
+		return map;
 	}
 
 	if (interlaced) {

Best regards,
Marek Vasut

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

"map" needs to be signed for the error handling to work. In the success case then it holds a small non-negative value.

Sascha

Quoted 24 lines
drivers/staging/imx-drm/ipu-v3/ipu-dc.c +3 -2
index 59f03f9..21bf1c8 100644
@@ -161,14 +161,15 @@ int ipu_dc_init_sync(struct ipu_dc *dc, struct ipu_di *di, bool interlaced,
 		u32 pixel_fmt, u32 width)
 {
 	struct ipu_dc_priv *priv = dc->priv;
-	u32 reg = 0, map;
+	u32 reg = 0;
+	int map;
 
 	dc->di = ipu_di_get_num(di);
 
 	map = ipu_pixfmt_to_map(pixel_fmt);
 	if (map < 0) {
 		dev_dbg(priv->dev, "IPU_DISP: No MAP\n");
-		return -EINVAL;
+		return map;
 	}
 
 	if (interlaced) {
Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |