kernel/taskstats.c: fix bogus nlmsg_free()

We'd better not nlmsg_free on a pointer containing an undefined value
(and without having anything allocated).

Spotted by the Coverity checker.

Signed-off-by: Adrian Bunk <bunk@kernel.org>
Acked-by: Balbir Singh <balbir@linux.vnet.ibm>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Adrian Bunk 2007-11-14 17:00:37 -08:00 committed by Linus Torvalds
parent 4ae44c5774
commit f96159840b
1 changed files with 18 additions and 18 deletions

View File

@ -398,31 +398,31 @@ static int cgroupstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
fd = nla_get_u32(info->attrs[CGROUPSTATS_CMD_ATTR_FD]); fd = nla_get_u32(info->attrs[CGROUPSTATS_CMD_ATTR_FD]);
file = fget_light(fd, &fput_needed); file = fget_light(fd, &fput_needed);
if (file) { if (!file)
size = nla_total_size(sizeof(struct cgroupstats)); return 0;
rc = prepare_reply(info, CGROUPSTATS_CMD_NEW, &rep_skb, size = nla_total_size(sizeof(struct cgroupstats));
size);
if (rc < 0)
goto err;
na = nla_reserve(rep_skb, CGROUPSTATS_TYPE_CGROUP_STATS, rc = prepare_reply(info, CGROUPSTATS_CMD_NEW, &rep_skb,
sizeof(struct cgroupstats)); size);
stats = nla_data(na); if (rc < 0)
memset(stats, 0, sizeof(*stats)); goto err;
rc = cgroupstats_build(stats, file->f_dentry); na = nla_reserve(rep_skb, CGROUPSTATS_TYPE_CGROUP_STATS,
if (rc < 0) sizeof(struct cgroupstats));
goto err; stats = nla_data(na);
memset(stats, 0, sizeof(*stats));
fput_light(file, fput_needed); rc = cgroupstats_build(stats, file->f_dentry);
return send_reply(rep_skb, info->snd_pid); if (rc < 0) {
nlmsg_free(rep_skb);
goto err;
} }
rc = send_reply(rep_skb, info->snd_pid);
err: err:
if (file) fput_light(file, fput_needed);
fput_light(file, fput_needed);
nlmsg_free(rep_skb);
return rc; return rc;
} }