Fix cb leak in case invalid type is specified in system_if_clear_entries
Detected by Coverity in CID1431183
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
system_if_clear_entries(struct device *dev, int type, int af)
{
struct clear_data clr;
system_if_clear_entries(struct device *dev, int type, int af)
{
struct clear_data clr;
- struct nl_cb *cb = nl_cb_alloc(NL_CB_DEFAULT);
struct rtmsg rtm = {
.rtm_family = af,
.rtm_flags = RTM_F_CLONED,
struct rtmsg rtm = {
.rtm_family = af,
.rtm_flags = RTM_F_CLONED,
int flags = NLM_F_DUMP;
int pending = 1;
int flags = NLM_F_DUMP;
int pending = 1;
clr.af = af;
clr.dev = dev;
clr.type = type;
clr.af = af;
clr.dev = dev;
clr.type = type;
+ cb = nl_cb_alloc(NL_CB_DEFAULT);
+ if (!cb)
+ return;
+
clr.msg = nlmsg_alloc_simple(type, flags);
if (!clr.msg)
goto out;
clr.msg = nlmsg_alloc_simple(type, flags);
if (!clr.msg)
goto out;