Skip to content

Commit

Permalink
msg: Remove unnecessary call of nlmsg_free on known NULL pointer
Browse files Browse the repository at this point in the history
In nlmsg_convert, if __nlmsg_alloc fails we can return NULL directly
instead of unnecessarily calling nlmsg_free on the NULL pointer.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Thomas Haller <thaller@redhat.com>
  • Loading branch information
tklauser authored and thom311 committed Jun 9, 2014
1 parent 1087eb5 commit 872544c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/msg.c
Expand Up @@ -385,14 +385,11 @@ struct nl_msg *nlmsg_convert(struct nlmsghdr *hdr)

nm = __nlmsg_alloc(NLMSG_ALIGN(hdr->nlmsg_len));
if (!nm)
goto errout;
return NULL;

memcpy(nm->nm_nlh, hdr, hdr->nlmsg_len);

return nm;
errout:
nlmsg_free(nm);
return NULL;
}

/**
Expand Down

0 comments on commit 872544c

Please sign in to comment.