aboutsummaryrefslogtreecommitdiffstats
path: root/net/caif/cfctrl.c
diff options
context:
space:
mode:
authorKim Lilliestierna XX <kim.xx.lilliestierna@stericsson.com>2012-06-25 03:49:35 -0400
committerDavid S. Miller <davem@davemloft.net>2012-06-25 19:44:11 -0400
commitf315fd355ffaec6a9ad541081975ac821404256e (patch)
treed3fe7940aa9b9d2c9e2329c900df3e4859da42a8 /net/caif/cfctrl.c
parentc95567c8035281d20ca8266cb39f8d48307a70af (diff)
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.c17
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)
175 175
176void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid) 176void cfctrl_enum_req(struct cflayer *layer, u8 physlinkid)
177{ 177{
178 struct cfpkt *pkt;
178 struct cfctrl *cfctrl = container_obj(layer); 179 struct cfctrl *cfctrl = container_obj(layer);
179 struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
180 struct cflayer *dn = cfctrl->serv.layer.dn; 180 struct cflayer *dn = cfctrl->serv.layer.dn;
181 if (!pkt) 181
182 return;
183 if (!dn) { 182 if (!dn) {
184 pr_debug("not able to send enum request\n"); 183 pr_debug("not able to send enum request\n");
185 return; 184 return;
186 } 185 }
186 pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
187 if (!pkt)
188 return;
187 caif_assert(offsetof(struct cfctrl, serv.layer) == 0); 189 caif_assert(offsetof(struct cfctrl, serv.layer) == 0);
188 init_info(cfpkt_info(pkt), cfctrl); 190 init_info(cfpkt_info(pkt), cfctrl);
189 cfpkt_info(pkt)->dev_info->id = physlinkid; 191 cfpkt_info(pkt)->dev_info->id = physlinkid;
@@ -302,18 +304,17 @@ int cfctrl_linkdown_req(struct cflayer *layer, u8 channelid,
302 struct cflayer *client) 304 struct cflayer *client)
303{ 305{
304 int ret; 306 int ret;
307 struct cfpkt *pkt;
305 struct cfctrl *cfctrl = container_obj(layer); 308 struct cfctrl *cfctrl = container_obj(layer);
306 struct cfpkt *pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
307 struct cflayer *dn = cfctrl->serv.layer.dn; 309 struct cflayer *dn = cfctrl->serv.layer.dn;
308 310
309 if (!pkt)
310 return -ENOMEM;
311
312 if (!dn) { 311 if (!dn) {
313 pr_debug("not able to send link-down request\n"); 312 pr_debug("not able to send link-down request\n");
314 return -ENODEV; 313 return -ENODEV;
315 } 314 }
316 315 pkt = cfpkt_create(CFPKT_CTRL_PKT_LEN);
316 if (!pkt)
317 return -ENOMEM;
317 cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_DESTROY); 318 cfpkt_addbdy(pkt, CFCTRL_CMD_LINK_DESTROY);
318 cfpkt_addbdy(pkt, channelid); 319 cfpkt_addbdy(pkt, channelid);
319 init_info(cfpkt_info(pkt), cfctrl); 320 init_info(cfpkt_info(pkt), cfctrl);