* [PATCH] cpuset : Handling improper memory allocation.
@ 2008-08-06 17:22 Rakib Mullick
2008-08-06 20:13 ` Max Krasnyansky
0 siblings, 1 reply; 4+ messages in thread
From: Rakib Mullick @ 2008-08-06 17:22 UTC (permalink / raw)
To: pj, menage; +Cc: linux-kernel
This patch makes sure that , if kmalloc fails in
"rebuild_sched_domains", then we've a place to go. If anything else,
please let me know.
Thanks.
Signed-off-by: Md.Rakib H. Mullick (rakib.mullick@gmail.com)
--- linux-2.6.27-rc2.orig/kernel/cpuset.c 2008-08-06 16:23:26.000000000 +0600
+++ linux-2.6.27-rc2/kernel/cpuset.c 2008-08-06 23:07:59.504441992 +0600
@@ -615,7 +615,8 @@ void rebuild_sched_domains(void)
if (dattr) {
*dattr = SD_ATTR_INIT;
update_domain_attr_tree(dattr, &top_cpuset);
- }
+ } else
+ goto rebuild;
*doms = top_cpuset.cpus_allowed;
goto rebuild;
}
@@ -685,6 +686,8 @@ restart:
if (!doms)
goto rebuild;
dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL);
+ if (!dattr)
+ goto rebuild;
for (nslot = 0, i = 0; i < csn; i++) {
struct cpuset *a = csa[i];
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] cpuset : Handling improper memory allocation.
2008-08-06 17:22 [PATCH] cpuset : Handling improper memory allocation Rakib Mullick
@ 2008-08-06 20:13 ` Max Krasnyansky
2008-08-06 20:37 ` Paul Jackson
0 siblings, 1 reply; 4+ messages in thread
From: Max Krasnyansky @ 2008-08-06 20:13 UTC (permalink / raw)
To: Rakib Mullick; +Cc: pj, menage, linux-kernel
Rakib Mullick wrote:
> This patch makes sure that , if kmalloc fails in
> "rebuild_sched_domains", then we've a place to go. If anything else,
> please let me know.
>
partition_sched_domains() can deal with attrs==NULL case. So we do not
have to abort domain building.
Max
> Thanks.
>
> Signed-off-by: Md.Rakib H. Mullick (rakib.mullick@gmail.com)
>
> --- linux-2.6.27-rc2.orig/kernel/cpuset.c 2008-08-06 16:23:26.000000000 +0600
> +++ linux-2.6.27-rc2/kernel/cpuset.c 2008-08-06 23:07:59.504441992 +0600
> @@ -615,7 +615,8 @@ void rebuild_sched_domains(void)
> if (dattr) {
> *dattr = SD_ATTR_INIT;
> update_domain_attr_tree(dattr, &top_cpuset);
> - }
> + } else
> + goto rebuild;
> *doms = top_cpuset.cpus_allowed;
> goto rebuild;
> }
> @@ -685,6 +686,8 @@ restart:
> if (!doms)
> goto rebuild;
> dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL);
> + if (!dattr)
> + goto rebuild;
>
> for (nslot = 0, i = 0; i < csn; i++) {
> struct cpuset *a = csa[i];
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] cpuset : Handling improper memory allocation.
2008-08-06 20:13 ` Max Krasnyansky
@ 2008-08-06 20:37 ` Paul Jackson
2008-08-06 20:43 ` Max Krasnyansky
0 siblings, 1 reply; 4+ messages in thread
From: Paul Jackson @ 2008-08-06 20:37 UTC (permalink / raw)
To: Max Krasnyansky; +Cc: rakib.mullick, menage, linux-kernel
Max wrote:
> partition_sched_domains() can deal with attrs==NULL case. So we do not
> have to abort domain building.
This might be a good place for a comment, since unchecked kmalloc()
calls look dangerous:
/* Convert <csn, csa> to <ndoms, doms> */
doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL);
if (!doms)
goto rebuild;
dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL);
/* dattr == NULL is ok; partition_sched_domains() can cope with it. */
--
I won't rest till it's the best ...
Programmer, Linux Scalability
Paul Jackson <pj@sgi.com> 1.940.382.4214
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] cpuset : Handling improper memory allocation.
2008-08-06 20:37 ` Paul Jackson
@ 2008-08-06 20:43 ` Max Krasnyansky
0 siblings, 0 replies; 4+ messages in thread
From: Max Krasnyansky @ 2008-08-06 20:43 UTC (permalink / raw)
To: Paul Jackson; +Cc: rakib.mullick, menage, linux-kernel
Paul Jackson wrote:
> Max wrote:
>> partition_sched_domains() can deal with attrs==NULL case. So we do not
>> have to abort domain building.
>
> This might be a good place for a comment, since unchecked kmalloc()
> calls look dangerous:
>
> /* Convert <csn, csa> to <ndoms, doms> */
> doms = kmalloc(ndoms * sizeof(cpumask_t), GFP_KERNEL);
> if (!doms)
> goto rebuild;
> dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL);
> /* dattr == NULL is ok; partition_sched_domains() can cope with it. */
Makes sense. I'll add it, since I'm touching that area anyway.
Max
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-08-06 20:44 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-08-06 17:22 [PATCH] cpuset : Handling improper memory allocation Rakib Mullick
2008-08-06 20:13 ` Max Krasnyansky
2008-08-06 20:37 ` Paul Jackson
2008-08-06 20:43 ` Max Krasnyansky
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.