mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH master 1/6] net: smc1111: add missing drive's of_device_id array sentinel
@ 2023-06-12 12:53 Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 2/6] scripts: remove openssl dependency in multi_v7_defconfig Ahmad Fatoum
                   ` (4 more replies)
  0 siblings, 5 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-06-12 12:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

ASAN on sandbox running allyesconfig detects that code reading
smc91c111_dt_ids reads out of bounds. This is because driver match tables
need to have sentinel elements, which was missing here. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/smc91111.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/smc91111.c b/drivers/net/smc91111.c
index a23f2ad129ff..cc8f5ed362f4 100644
--- a/drivers/net/smc91111.c
+++ b/drivers/net/smc91111.c
@@ -1492,6 +1492,7 @@ static __maybe_unused struct of_device_id smc91c111_dt_ids[] = {
 	{
 		.compatible = "smsc,lan91c111",
 	},
+	{ /* sentinel */ },
 };
 
 static struct driver smc91c111_driver = {
-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH master 2/6] scripts: remove openssl dependency in multi_v7_defconfig
  2023-06-12 12:53 [PATCH master 1/6] net: smc1111: add missing drive's of_device_id array sentinel Ahmad Fatoum
@ 2023-06-12 12:53 ` Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 3/6] clocksource: armv7m_systick: fix MMIO address Ahmad Fatoum
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-06-12 12:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

The 32-bit rockchip support doesn't use the rkimage tool and instead
depends on mkimage to wrap the barebox binary. There's thus no need to
compile the rkimage utility for 32-bit barebox builds. This is a good
thing, because it removes the openssl dependency as the library is used
for sha256/sha512 calculation.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 scripts/Kconfig | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/Kconfig b/scripts/Kconfig
index dcd5f32d1df1..26c6a3c19806 100644
--- a/scripts/Kconfig
+++ b/scripts/Kconfig
@@ -51,8 +51,8 @@ config STM32_IMAGE
 
 config RK_IMAGE
 	bool "Rockchip image tool" if COMPILE_HOST_TOOLS
-	depends on ARCH_ROCKCHIP || COMPILE_HOST_TOOLS
-	default y if ARCH_ROCKCHIP
+	depends on ARCH_ROCKCHIP_V8 || COMPILE_HOST_TOOLS
+	default y if ARCH_ROCKCHIP_V8
 	help
 	  This enables building the image creation tool for Rockchip SoCs
 
-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH master 3/6] clocksource: armv7m_systick: fix MMIO address
  2023-06-12 12:53 [PATCH master 1/6] net: smc1111: add missing drive's of_device_id array sentinel Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 2/6] scripts: remove openssl dependency in multi_v7_defconfig Ahmad Fatoum
@ 2023-06-12 12:53 ` Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 4/6] of: select OF_OVERLAY where appropriate Ahmad Fatoum
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-06-12 12:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

SYST_CALIB is a register within the ARMv7-M SysTick peripheral, but we
erroneously dereferenced some random spot within the barebox data
section. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/clocksource/armv7m_systick.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/clocksource/armv7m_systick.c b/drivers/clocksource/armv7m_systick.c
index f299d334a76e..33ac426878ba 100644
--- a/drivers/clocksource/armv7m_systick.c
+++ b/drivers/clocksource/armv7m_systick.c
@@ -64,7 +64,7 @@ static int armv7m_systick_probe(struct device *dev)
 
 	writel_relaxed(SYSTICK_LOAD_RELOAD_MASK, systick_base + SYST_RVR);
 
-	cal = readl(&systick_base + SYST_CALIB);
+	cal = readl(systick_base + SYST_CALIB);
 	if (cal & SYSTICK_CAL_NOREF)
 		writel(SYSTICK_CTRL_EN | SYSTICK_CTRL_CPU_CLK, systick_base + SYST_CSR);
 	else
-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH master 4/6] of: select OF_OVERLAY where appropriate
  2023-06-12 12:53 [PATCH master 1/6] net: smc1111: add missing drive's of_device_id array sentinel Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 2/6] scripts: remove openssl dependency in multi_v7_defconfig Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 3/6] clocksource: armv7m_systick: fix MMIO address Ahmad Fatoum
@ 2023-06-12 12:53 ` Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 5/6] memory_display: don't skip va_end in error case Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 6/6] regmap-mmio: fix use-after-free Ahmad Fatoum
  4 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-06-12 12:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Both Qemu Virt and riscvemu depend on OF_OVERLAY to apply overlays, but
don't care for symbols in the barebox DT (and thus don't need
OF_OVERLAY_LIVE). Reflect this in the Kconfig.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 arch/riscv/Kconfig.socs | 1 +
 common/boards/Kconfig   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/arch/riscv/Kconfig.socs b/arch/riscv/Kconfig.socs
index 2cb0716cd527..56ba5ecf5865 100644
--- a/arch/riscv/Kconfig.socs
+++ b/arch/riscv/Kconfig.socs
@@ -38,6 +38,7 @@ config BOARD_RISCV_VIRT
 config BOARD_RISCVEMU
 	depends on SOC_VIRT
 	bool "TinyEMU Virt Machine (riscvemu)"
+	select OF_OVERLAY
 	default y
 	help
 	  TinyEMU's Virt machine differs from QEMU in poweroff and restart
diff --git a/common/boards/Kconfig b/common/boards/Kconfig
index e27273b7671d..3ac3dcbe0406 100644
--- a/common/boards/Kconfig
+++ b/common/boards/Kconfig
@@ -2,3 +2,4 @@
 
 config BOARD_QEMU_VIRT
 	bool
+	select OF_OVERLAY
-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH master 5/6] memory_display: don't skip va_end in error case
  2023-06-12 12:53 [PATCH master 1/6] net: smc1111: add missing drive's of_device_id array sentinel Ahmad Fatoum
                   ` (2 preceding siblings ...)
  2023-06-12 12:53 ` [PATCH master 4/6] of: select OF_OVERLAY where appropriate Ahmad Fatoum
@ 2023-06-12 12:53 ` Ahmad Fatoum
  2023-06-12 12:53 ` [PATCH master 6/6] regmap-mmio: fix use-after-free Ahmad Fatoum
  4 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-06-12 12:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

There's a va_start at the start of __pr_memory_display, but va_end was
only called in the successful case. Fix this.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/memory_display.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/memory_display.c b/common/memory_display.c
index 77868be26ace..c0ca469703d3 100644
--- a/common/memory_display.c
+++ b/common/memory_display.c
@@ -123,9 +123,9 @@ int __pr_memory_display(int level, const void *addr, loff_t offs, unsigned nbyte
 
 	} while (nbytes > 0);
 
-	va_end(args);
 	ret = 0;
 out:
+	va_end(args);
 
 	return ret;
 }
-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH master 6/6] regmap-mmio: fix use-after-free
  2023-06-12 12:53 [PATCH master 1/6] net: smc1111: add missing drive's of_device_id array sentinel Ahmad Fatoum
                   ` (3 preceding siblings ...)
  2023-06-12 12:53 ` [PATCH master 5/6] memory_display: don't skip va_end in error case Ahmad Fatoum
@ 2023-06-12 12:53 ` Ahmad Fatoum
  2023-06-13  7:11   ` Sascha Hauer
  4 siblings, 1 reply; 8+ messages in thread
From: Ahmad Fatoum @ 2023-06-12 12:53 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

Once we free ctx, dereferencing it to return ERR_CAST(ctx->clk) is
verboten. Fix this by using an intermediary variable.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/base/regmap/regmap-mmio.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
index 6e6ae5ed54d4..4c6389689cd6 100644
--- a/drivers/base/regmap/regmap-mmio.c
+++ b/drivers/base/regmap/regmap-mmio.c
@@ -289,11 +289,15 @@ struct regmap *regmap_init_mmio_clk(struct device *dev,
 		return ERR_CAST(ctx);
 
 	if (clk_id) {
-		ctx->clk = clk_get(dev, clk_id);
-		if (IS_ERR(ctx->clk)) {
+		struct clk *clk;
+
+		clk = clk_get(dev, clk_id);
+		if (IS_ERR(clk)) {
 			kfree(ctx);
-			return ERR_CAST(ctx->clk);
+			return ERR_CAST(clk);
 		}
+
+		ctx->clk = clk;
 	}
 
 	return regmap_init(dev, &regmap_mmio, ctx, config);
-- 
2.39.2




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH master 6/6] regmap-mmio: fix use-after-free
  2023-06-12 12:53 ` [PATCH master 6/6] regmap-mmio: fix use-after-free Ahmad Fatoum
@ 2023-06-13  7:11   ` Sascha Hauer
  2023-06-13  7:17     ` Ahmad Fatoum
  0 siblings, 1 reply; 8+ messages in thread
From: Sascha Hauer @ 2023-06-13  7:11 UTC (permalink / raw)
  To: Ahmad Fatoum; +Cc: barebox

On Mon, Jun 12, 2023 at 02:53:31PM +0200, Ahmad Fatoum wrote:
> Once we free ctx, dereferencing it to return ERR_CAST(ctx->clk) is
> verboten. Fix this by using an intermediary variable.

Looks funny like this, but replaced with forbidden for the non german
speakers ;)

Applied all, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH master 6/6] regmap-mmio: fix use-after-free
  2023-06-13  7:11   ` Sascha Hauer
@ 2023-06-13  7:17     ` Ahmad Fatoum
  0 siblings, 0 replies; 8+ messages in thread
From: Ahmad Fatoum @ 2023-06-13  7:17 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 13.06.23 09:11, Sascha Hauer wrote:
> On Mon, Jun 12, 2023 at 02:53:31PM +0200, Ahmad Fatoum wrote:
>> Once we free ctx, dereferencing it to return ERR_CAST(ctx->clk) is
>> verboten. Fix this by using an intermediary variable.
> 
> Looks funny like this, but replaced with forbidden for the non german
> speakers ;)

It was borrowed into English and is listed in Merriam-Webster's Official
Scrabble Players Dictionary, 5th Edition!

Thanks,
Ahmad

> 
> Applied all, thanks
> 
> Sascha
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-06-13  7:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-12 12:53 [PATCH master 1/6] net: smc1111: add missing drive's of_device_id array sentinel Ahmad Fatoum
2023-06-12 12:53 ` [PATCH master 2/6] scripts: remove openssl dependency in multi_v7_defconfig Ahmad Fatoum
2023-06-12 12:53 ` [PATCH master 3/6] clocksource: armv7m_systick: fix MMIO address Ahmad Fatoum
2023-06-12 12:53 ` [PATCH master 4/6] of: select OF_OVERLAY where appropriate Ahmad Fatoum
2023-06-12 12:53 ` [PATCH master 5/6] memory_display: don't skip va_end in error case Ahmad Fatoum
2023-06-12 12:53 ` [PATCH master 6/6] regmap-mmio: fix use-after-free Ahmad Fatoum
2023-06-13  7:11   ` Sascha Hauer
2023-06-13  7:17     ` Ahmad Fatoum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox