* [PATCH] mm: add NULL check to avoid potential NULL pointer dereference
@ 2017-05-30 21:24 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-30 21:24 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, Gustavo A. R. Silva
NULL check at line 1226: if (!pgdat), implies that pointer pgdat
might be NULL.
Function rollback_node_hotadd() dereference this pointer.
Add NULL check to avoid a potential NULL pointer dereference.
Addresses-Coverity-ID: 1369133
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
mm/memory_hotplug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 599c675..ea3bc3e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1273,7 +1273,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
error:
/* rollback pgdat allocation and others */
- if (new_pgdat)
+ if (new_pgdat && pgdat)
rollback_node_hotadd(nid, pgdat);
memblock_remove(start, size);
--
2.5.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] mm: add NULL check to avoid potential NULL pointer dereference
@ 2017-05-30 21:24 ` Gustavo A. R. Silva
0 siblings, 0 replies; 4+ messages in thread
From: Gustavo A. R. Silva @ 2017-05-30 21:24 UTC (permalink / raw)
To: linux-mm; +Cc: linux-kernel, Gustavo A. R. Silva
NULL check at line 1226: if (!pgdat), implies that pointer pgdat
might be NULL.
Function rollback_node_hotadd() dereference this pointer.
Add NULL check to avoid a potential NULL pointer dereference.
Addresses-Coverity-ID: 1369133
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
mm/memory_hotplug.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
index 599c675..ea3bc3e 100644
--- a/mm/memory_hotplug.c
+++ b/mm/memory_hotplug.c
@@ -1273,7 +1273,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
error:
/* rollback pgdat allocation and others */
- if (new_pgdat)
+ if (new_pgdat && pgdat)
rollback_node_hotadd(nid, pgdat);
memblock_remove(start, size);
--
2.5.0
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: add NULL check to avoid potential NULL pointer dereference
2017-05-30 21:24 ` Gustavo A. R. Silva
@ 2017-05-31 15:09 ` Michal Hocko
-1 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2017-05-31 15:09 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: linux-mm, linux-kernel
On Tue 30-05-17 16:24:36, Gustavo A. R. Silva wrote:
> NULL check at line 1226: if (!pgdat), implies that pointer pgdat
> might be NULL.
> Function rollback_node_hotadd() dereference this pointer.
> Add NULL check to avoid a potential NULL pointer dereference.
The changelog is quite cryptic to be honest. Well the code is as well
but what do you say about the following replacement.
"
If a new pgdat has to be allocated in add_memory_resource
and the initialization fails for some reason we have to
rollback_node_hotadd. This, however, assumes that pgdat allocation
itself is successful which cannot be assumed. Add a check for pgdat
to cover that case and skip rollback_node_hotadd altogether because
there is nothing to roll back.
This has been pointed out by coverity.
"
>
> Addresses-Coverity-ID: 1369133
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memory_hotplug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 599c675..ea3bc3e 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1273,7 +1273,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
>
> error:
> /* rollback pgdat allocation and others */
> - if (new_pgdat)
> + if (new_pgdat && pgdat)
> rollback_node_hotadd(nid, pgdat);
> memblock_remove(start, size);
>
> --
> 2.5.0
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mm: add NULL check to avoid potential NULL pointer dereference
@ 2017-05-31 15:09 ` Michal Hocko
0 siblings, 0 replies; 4+ messages in thread
From: Michal Hocko @ 2017-05-31 15:09 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: linux-mm, linux-kernel
On Tue 30-05-17 16:24:36, Gustavo A. R. Silva wrote:
> NULL check at line 1226: if (!pgdat), implies that pointer pgdat
> might be NULL.
> Function rollback_node_hotadd() dereference this pointer.
> Add NULL check to avoid a potential NULL pointer dereference.
The changelog is quite cryptic to be honest. Well the code is as well
but what do you say about the following replacement.
"
If a new pgdat has to be allocated in add_memory_resource
and the initialization fails for some reason we have to
rollback_node_hotadd. This, however, assumes that pgdat allocation
itself is successful which cannot be assumed. Add a check for pgdat
to cover that case and skip rollback_node_hotadd altogether because
there is nothing to roll back.
This has been pointed out by coverity.
"
>
> Addresses-Coverity-ID: 1369133
> Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Michal Hocko <mhocko@suse.com>
> ---
> mm/memory_hotplug.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> index 599c675..ea3bc3e 100644
> --- a/mm/memory_hotplug.c
> +++ b/mm/memory_hotplug.c
> @@ -1273,7 +1273,7 @@ int __ref add_memory_resource(int nid, struct resource *res, bool online)
>
> error:
> /* rollback pgdat allocation and others */
> - if (new_pgdat)
> + if (new_pgdat && pgdat)
> rollback_node_hotadd(nid, pgdat);
> memblock_remove(start, size);
>
> --
> 2.5.0
>
> --
> To unsubscribe, send a message with 'unsubscribe linux-mm' in
> the body to majordomo@kvack.org. For more info on Linux MM,
> see: http://www.linux-mm.org/ .
> Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
--
Michal Hocko
SUSE Labs
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-31 15:09 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-30 21:24 [PATCH] mm: add NULL check to avoid potential NULL pointer dereference Gustavo A. R. Silva
2017-05-30 21:24 ` Gustavo A. R. Silva
2017-05-31 15:09 ` Michal Hocko
2017-05-31 15:09 ` Michal Hocko
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.