Re: [PATCH] kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end()
Hello maintainers: Please help check this patch, when you have time. Thanks. On 08/20/2013 10:44 AM, Chen Gang wrote: > When failure occurs between nla_nest_start() and nla_nest_end(), need > call nla_nest_cancel() to clean up related things. > > Signed-off-by: Chen Gang > --- > kernel/taskstats.c |8 ++-- > 1 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/kernel/taskstats.c b/kernel/taskstats.c > index 145bb4d..1db6808 100644 > --- a/kernel/taskstats.c > +++ b/kernel/taskstats.c > @@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, > int type, u32 pid) > if (!na) > goto err; > > - if (nla_put(skb, type, sizeof(pid), ) < 0) > + if (nla_put(skb, type, sizeof(pid), ) < 0) { > + nla_nest_cancel(skb, na); > goto err; > + } > ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); > - if (!ret) > + if (!ret) { > + nla_nest_cancel(skb, na); > goto err; > + } > nla_nest_end(skb, na); > > return nla_data(ret); > -- Chen Gang -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH] kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end()
Hello maintainers: Please help check this patch, when you have time. Thanks. On 08/20/2013 10:44 AM, Chen Gang wrote: When failure occurs between nla_nest_start() and nla_nest_end(), need call nla_nest_cancel() to clean up related things. Signed-off-by: Chen Gang gang.c...@asianux.com --- kernel/taskstats.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 145bb4d..1db6808 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid) if (!na) goto err; - if (nla_put(skb, type, sizeof(pid), pid) 0) + if (nla_put(skb, type, sizeof(pid), pid) 0) { + nla_nest_cancel(skb, na); goto err; + } ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); - if (!ret) + if (!ret) { + nla_nest_cancel(skb, na); goto err; + } nla_nest_end(skb, na); return nla_data(ret); -- Chen Gang -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end()
When failure occurs between nla_nest_start() and nla_nest_end(), need call nla_nest_cancel() to clean up related things. Signed-off-by: Chen Gang --- kernel/taskstats.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 145bb4d..1db6808 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid) if (!na) goto err; - if (nla_put(skb, type, sizeof(pid), ) < 0) + if (nla_put(skb, type, sizeof(pid), ) < 0) { + nla_nest_cancel(skb, na); goto err; + } ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); - if (!ret) + if (!ret) { + nla_nest_cancel(skb, na); goto err; + } nla_nest_end(skb, na); return nla_data(ret); -- 1.7.7.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH] kernel/taskstats.c: add nla_nest_cancel() for failure processing between nla_nest_start() and nla_nest_end()
When failure occurs between nla_nest_start() and nla_nest_end(), need call nla_nest_cancel() to clean up related things. Signed-off-by: Chen Gang gang.c...@asianux.com --- kernel/taskstats.c |8 ++-- 1 files changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/taskstats.c b/kernel/taskstats.c index 145bb4d..1db6808 100644 --- a/kernel/taskstats.c +++ b/kernel/taskstats.c @@ -404,11 +404,15 @@ static struct taskstats *mk_reply(struct sk_buff *skb, int type, u32 pid) if (!na) goto err; - if (nla_put(skb, type, sizeof(pid), pid) 0) + if (nla_put(skb, type, sizeof(pid), pid) 0) { + nla_nest_cancel(skb, na); goto err; + } ret = nla_reserve(skb, TASKSTATS_TYPE_STATS, sizeof(struct taskstats)); - if (!ret) + if (!ret) { + nla_nest_cancel(skb, na); goto err; + } nla_nest_end(skb, na); return nla_data(ret); -- 1.7.7.6 -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/