diff options
author | Kim Lilliestierna XX <kim.xx.lilliestierna@stericsson.com> | 2012-06-25 07:49:35 +0000 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-25 16:44:11 -0700 |
commit | f315fd355ffaec6a9ad541081975ac821404256e (patch) | |
tree | d3fe7940aa9b9d2c9e2329c900df3e4859da42a8 /net/caif/cfctrl.c | |
parent | c95567c8035281d20ca8266cb39f8d48307a70af (diff) | |
download | linux-f315fd355ffaec6a9ad541081975ac821404256e.tar.bz2 |
caif: Fixed potential memory leak
Rearranged the allocation and packet creations to
avoid potential leaks in error path.
Signed-off-by: Kim Lilliestierna <kim.xx.lilliestierna@stericsson.com>
Signed-off-by: Sjur Brændeland <sjur.brandeland@stericssion.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/caif/cfctrl.c')
-rw-r--r-- | net/caif/cfctrl.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c index 047cd0eec022..44f270fc2d06 100644 --- a/net/caif/cfctrl.c +++ b/net/caif/cfctrl.c @@ -175,15 +175,17 @@ static void init_info(struct caif_payload_info *info, struct cfctrl *cfctrl) void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid) { + struct cfpkt *pkt; struct cfctrl *cfctrl = container_obj(layer); - struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); struct cflayer *dn = cfctrl->serv.layer.dn; - if (!pkt) - return; + if (!dn) { pr_debug("not able to send enum request\n"); return; } + pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); + if (!pkt) + return; caif_assert(offsetof(struct cfctrl, serv.layer) == 0); init_info(cfpkt_info(pkt), cfctrl); cfpkt_info(pkt)->dev_info->id = physlinkid; @@ -302,18 +304,17 @@ int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid, struct cflayer *client) { int ret; + struct cfpkt *pkt; struct cfctrl *cfctrl = container_obj(layer); - struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); struct cflayer *dn = cfctrl->serv.layer.dn; - if (!pkt) - return -ENOMEM; - if (!dn) { pr_debug("not able to send link-down request\n"); return -ENODEV; } - + pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN); + if (!pkt) + return -ENOMEM; cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_DESTROY); cfpkt_addbdy(pkt, channelid); init_info(cfpkt_info(pkt), cfctrl); |