提交 bc0384ee 编写于 作者: C Colin Ian King 提交者: Kalle Valo

qtnfmac: check band before allocating cmd_skb to avoid resource leak

The current code allocates cmd_skb and then will leak this if band->band
is an illegal value. It is simpler to sanity check the band first before
allocating cmd_skb so that we don't have to free cmd_skb if an invalid
band occurs.

Detected by CoverityScan, CID#1437561 ("Resource Leak")
Signed-off-by: NColin Ian King <colin.king@canonical.com>
Reviewed-by: NIgor Mitsyanko <igor.mitsyanko.os@quantenna.com>
Signed-off-by: NKalle Valo <kvalo@codeaurora.org>
上级 292c3333
......@@ -1300,12 +1300,6 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
int ret = 0;
u8 qband;
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
QLINK_CMD_CHANS_INFO_GET,
sizeof(*cmd));
if (!cmd_skb)
return -ENOMEM;
switch (band->band) {
case NL80211_BAND_2GHZ:
qband = QLINK_BAND_2GHZ;
......@@ -1320,6 +1314,12 @@ int qtnf_cmd_get_mac_chan_info(struct qtnf_wmac *mac,
return -EINVAL;
}
cmd_skb = qtnf_cmd_alloc_new_cmdskb(mac->macid, 0,
QLINK_CMD_CHANS_INFO_GET,
sizeof(*cmd));
if (!cmd_skb)
return -ENOMEM;
cmd = (struct qlink_cmd_chans_info_get *)cmd_skb->data;
cmd->band = qband;
ret = qtnf_cmd_send_with_reply(mac->bus, cmd_skb, &resp_skb, &res_code,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册