mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mach-mvebu: coherency: Judgment after pointer p increases allocation
@ 2022-11-21 10:01 Li zeming
  2022-11-22  0:19 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Li zeming @ 2022-11-21 10:01 UTC (permalink / raw)
  To: andrew, gregory.clement, sebastian.hesselbarth
  Cc: linux, linux-arm-kernel, linux-kernel, Li zeming

Add judgment statements at the position after pointer p allocates memory
to avoid the abnormal impact of low probability allocation failure.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 arch/arm/mach-mvebu/coherency.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
index a6b621ff0b87..2bc69dd059d6 100644
--- a/arch/arm/mach-mvebu/coherency.c
+++ b/arch/arm/mach-mvebu/coherency.c
@@ -191,8 +191,10 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
 		struct property *p;
 
 		p = kzalloc(sizeof(*p), GFP_KERNEL);
-		p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
-		of_add_property(cache_dn, p);
+		if (p) {
+			p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
+			of_add_property(cache_dn, p);
+		}
 	}
 }
 
-- 
2.18.2


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

* Re: [PATCH] mach-mvebu: coherency: Judgment after pointer p increases allocation
  2022-11-21 10:01 [PATCH] mach-mvebu: coherency: Judgment after pointer p increases allocation Li zeming
@ 2022-11-22  0:19 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2022-11-22  0:19 UTC (permalink / raw)
  To: Li zeming
  Cc: gregory.clement, sebastian.hesselbarth, linux, linux-arm-kernel,
	linux-kernel

On Mon, Nov 21, 2022 at 06:01:22PM +0800, Li zeming wrote:
> Add judgment statements at the position after pointer p allocates memory
> to avoid the abnormal impact of low probability allocation failure.
> 
> Signed-off-by: Li zeming <zeming@nfschina.com>
> ---
>  arch/arm/mach-mvebu/coherency.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c
> index a6b621ff0b87..2bc69dd059d6 100644
> --- a/arch/arm/mach-mvebu/coherency.c
> +++ b/arch/arm/mach-mvebu/coherency.c
> @@ -191,8 +191,10 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
>  		struct property *p;
>  
>  		p = kzalloc(sizeof(*p), GFP_KERNEL);
> -		p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
> -		of_add_property(cache_dn, p);
> +		if (p) {
> +			p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
> +			of_add_property(cache_dn, p);
> +		}

The comment before this says:
	/*
	 * Add the PL310 property "arm,io-coherent". This makes sure the
	 * outer sync operation is not used, which allows to
	 * workaround the system erratum that causes deadlocks when
	 * doing PCIe in an SMP situation on Armada 375 and Armada
	 * 38x.
	 */

Skipping adding the property because we are out of memory is probably
not a good idea, it is going to cause very hard to find deadlocks.
Actually being out of memory so early in the boot indicates something
very bad is going on anyway. So i think dereferencing the NULL pointer
is the least of our worries.

If you really want to do some sort of check here, BUG_ON(!p);

   Andrew

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

end of thread, other threads:[~2022-11-22  0:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-21 10:01 [PATCH] mach-mvebu: coherency: Judgment after pointer p increases allocation Li zeming
2022-11-22  0:19 ` Andrew Lunn

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

all inboxes | Powered by JetHome®