Skip to contentSkip to conversation

compiler: avoid redefining symbols when running with checker

PATCH In review Lucas Stach 2 participants 9 messages Jul 6, 2016 – Jul 7, 2016

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

PATCH 1/7 compiler: avoid redefining symbols when running with checker

Avoid redefining __user and __kernel if running with a checker enabled.

---
 include/linux/compiler.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/compiler.h +2 -2
index 020ad16..91331dd 100644
@@ -4,8 +4,8 @@
 #ifndef __ASSEMBLY__
 
 #ifdef __CHECKER__
-# define __user		__attribute__((noderef, address_space(1)))
-# define __kernel	__attribute__((address_space(0)))
+# define __user		/* no user address space in barebox */
+# define __kernel	/* default address space */
 # define __safe		__attribute__((safe))
 # define __force	__attribute__((force))
 # define __nocast	__attribute__((nocast))
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/7 USB: gadget: composite: avoid possible NULL ptr dereference

Check if g is valid before trying to dereference it.

---
 drivers/usb/gadget/composite.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/usb/gadget/composite.c +3 -1
index 9e38ac4..1cfc49d 100644
@@ -86,7 +86,7 @@ int config_ep_by_speed(struct usb_gadget *g,
 			struct usb_function *f,
 			struct usb_ep *_ep)
 {
-	struct usb_composite_dev	*cdev = get_gadget_data(g);
+	struct usb_composite_dev *cdev;
 	struct usb_endpoint_descriptor *chosen_desc = NULL;
 	struct usb_descriptor_header **speed_desc = NULL;
 
@@ -98,6 +98,8 @@ int config_ep_by_speed(struct usb_gadget *g,
 	if (!g || !f || !_ep)
 		return -EIO;
 
+	cdev = get_gadget_data(g);
+
 	/* select desired speed */
 	switch (g->speed) {
 	case USB_SPEED_SUPER:
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 4/7 imx-bbu-nand-fcb: don't drop error return code

In reply to Lucas Stach

bit_to_flip might be negative if any uncorrectable bitflips occured. Use int instead of unsigned type in order to properly propagate the error.

---
 common/imx-bbu-nand-fcb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
common/imx-bbu-nand-fcb.c +2 -2
index 72b7b0e..ce00ed4 100644
@@ -259,8 +259,8 @@ static ssize_t raw_write_page(struct mtd_info *mtd, void *buf, loff_t offset)
 static int read_fcb(struct mtd_info *mtd, int num, struct fcb_block **retfcb)
 {
 	int i;
-	int bitflips = 0;
-	u8 parity, np, syndrome, bit_to_flip;
+	int bitflips = 0, bit_to_flip;
+	u8 parity, np, syndrome;
 	u8 *fcb, *ecc;
 	int ret;
 	void *rawpage;
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 6/7 clk: fix misleading indenting

In reply to Lucas Stach
---
 drivers/clk/clkdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/clkdev.c +2 -2
index d9a1c21..1bc5c6d 100644
@@ -181,8 +181,8 @@ struct clk *clk_get(struct device_d *dev, const char *con_id)
 
 	if (dev) {
 		clk = of_clk_get_by_name(dev->device_node, con_id);
-			if (!IS_ERR(clk))
-				return clk;
+		if (!IS_ERR(clk))
+			return clk;
 	}
 
 	return clk_get_sys(dev_id, con_id);
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 7/7 blspec: use correct return type

In reply to Lucas Stach
---
 common/blspec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/blspec.c +1 -1
index bf98e6b..04b20fb 100644
@@ -253,7 +253,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	const char *abspath;
 	size_t size;
 	void *fdt = NULL;
-	int ret;
+	bool ret;
 	struct device_node *root = NULL, *barebox_root;
 	const char *compat;
 	char *filename;
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/7 video: displaytimings: don't double free display timings

In reply to Lucas Stach

display_timings_release() already frees the disp struct, make sure to not try to free it again in case of an error.

---
 drivers/video/of_display_timing.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/video/of_display_timing.c +2 -3
index 6a5bf62..6532dd5 100644
@@ -163,7 +163,8 @@ struct display_timings *of_get_display_timings(struct device_node *np)
 			 */
 			pr_err("%s: error in timing %d\n",
 				np->full_name, disp->num_modes + 1);
-			goto timingfail;
+			display_timings_release(disp);
+			return NULL;
 		}
 
 		mode->name = xstrdup(entry->name);
@@ -180,8 +181,6 @@ struct display_timings *of_get_display_timings(struct device_node *np)
 
 	return disp;
 
-timingfail:
-	display_timings_release(disp);
 entryfail:
 	free(disp);
 
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 5/7 imx-bbu-nand-fcb: avoid double free of dbbt_entries

In reply to Lucas Stach

The error path properly frees them already.

---
 common/imx-bbu-nand-fcb.c | 1 -
 1 file changed, 1 deletion(-)
common/imx-bbu-nand-fcb.c +0 -1
index ce00ed4..1db4c5a 100644
@@ -658,7 +658,6 @@ static int dbbt_check(struct mtd_info *mtd, int page)
 			needs_cleanup = 1;
 		} else if (ret < 0) {
 			pr_err("Cannot read page %d: %s\n", page, strerror(-ret));
-			free(dbbt_entries);
 			goto out;
 		}
 	} else {
Signature · 7 lines
2.7.4


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#3 lore raw

Re: [PATCH 3/7] video: displaytimings: don't double free display timings

In reply to Lucas Stach
Quoted 23 lines · Lucas Stach

display_timings_release() already frees the disp struct, make sure to not try to free it again in case of an error.

---
 drivers/video/of_display_timing.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/video/of_display_timing.c +2 -1
index 6a5bf62..6532dd5 100644
@@ -163,7 +163,8 @@ struct display_timings *of_get_display_timings(struct device_node *np)
 			 */
 			pr_err("%s: error in timing %d\n",
 				np->full_name, disp->num_modes + 1);
-			goto timingfail;
+			display_timings_release(disp);
+			return NULL;
 		}
 
 		mode->name = xstrdup(entry->name);

drivers/video/of_display_timing.c struct display_timings *of_get_display_timings(struct device_node *np) · line 185

Quoted 7 lines
drivers/video/of_display_timing.c +0 -2
@@ -180,8 +181,6 @@ struct display_timings *of_get_display_timings(struct device_node *np)
 
 	return disp;
 
-timingfail:
-	display_timings_release(disp);
 entryfail:
 	free(disp);

Can't we just always use display_timings_release() instead of free?

Sascha

Signature · 9 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 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#8 lore raw

Re: [PATCH 7/7] blspec: use correct return type

In reply to Lucas Stach
Quoted 10 lines · Lucas Stach
---
 common/blspec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/blspec.c +0 -0
index bf98e6b..04b20fb 100644

common/blspec.c static bool entry_is_of_compatible(struct blspec_entry *entry) · line 259

Quoted 8 lines
common/blspec.c +1 -1
@@ -253,7 +253,7 @@ static bool entry_is_of_compatible(struct blspec_entry *entry)
 	const char *abspath;
 	size_t size;
 	void *fdt = NULL;
-	int ret;
+	bool ret;
 	struct device_node *root = NULL, *barebox_root;
 	const char *compat;
 	char *filename;

I suspect this is not the only bug in this function. We also do a:

	root = of_unflatten_dtb(fdt);
	if (IS_ERR(root)) {
		ret = PTR_ERR(root);
		goto out;
	}

...

out:

	return ret;

So we return 'true' when we failed unflattening the device tree, this surely is not intended. Should the function return int instead?

Sascha

Signature · 9 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 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox