* [PATCH] sch_gred: kzalloc needs null check
@ 2019-07-19 1:30 Navid Emamdoost
2019-07-19 1:42 ` Eric Dumazet
0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-07-19 1:30 UTC (permalink / raw)
Cc: emamd001, kjlu, smccaman, Navid Emamdoost, Jamal Hadi Salim,
Cong Wang, Jiri Pirko, David S. Miller, netdev, linux-kernel
call to kzalloc may fail and return null. So the result should be checked
against null. Added the check to cover kzalloc failure case.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
net/sched/sch_gred.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
index 8599c6f31b05..5cd0859f0274 100644
--- a/net/sched/sch_gred.c
+++ b/net/sched/sch_gred.c
@@ -697,6 +697,9 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt,
}
prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
+ if (!prealloc)
+ return -ENOMEM;
+
sch_tree_lock(sch);
err = gred_change_vq(sch, ctl->DP, ctl, prio, stab, max_P, &prealloc,
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] sch_gred: kzalloc needs null check
2019-07-19 1:30 [PATCH] sch_gred: kzalloc needs null check Navid Emamdoost
@ 2019-07-19 1:42 ` Eric Dumazet
0 siblings, 0 replies; 2+ messages in thread
From: Eric Dumazet @ 2019-07-19 1:42 UTC (permalink / raw)
To: Navid Emamdoost
Cc: emamd001, kjlu, smccaman, Jamal Hadi Salim, Cong Wang,
Jiri Pirko, David S. Miller, netdev, linux-kernel
On 7/19/19 3:30 AM, Navid Emamdoost wrote:
> call to kzalloc may fail and return null. So the result should be checked
> against null. Added the check to cover kzalloc failure case.
>
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> net/sched/sch_gred.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
> index 8599c6f31b05..5cd0859f0274 100644
> --- a/net/sched/sch_gred.c
> +++ b/net/sched/sch_gred.c
> @@ -697,6 +697,9 @@ static int gred_change(struct Qdisc *sch, struct nlattr *opt,
> }
>
> prealloc = kzalloc(sizeof(*prealloc), GFP_KERNEL);
> + if (!prealloc)
> + return -ENOMEM;
> +
> sch_tree_lock(sch);
>
> err = gred_change_vq(sch, ctl->DP, ctl, prio, stab, max_P, &prealloc,
>
This seems not needed.
The case is handled later in gred_change_vq()
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-19 1:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 1:30 [PATCH] sch_gred: kzalloc needs null check Navid Emamdoost
2019-07-19 1:42 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).