Skip to content

Commit 4d0fa7a

Browse files
AlexiousLuvijay-suman
authored andcommitted
wifi: libertas: fix some memleaks in lbs_allocate_cmd_buffer()
[ Upstream commit 5f0e4ae ] In the for statement of lbs_allocate_cmd_buffer(), if the allocation of cmdarray[i].cmdbuf fails, both cmdarray and cmdarray[i].cmdbuf needs to be freed. Otherwise, there will be memleaks in lbs_allocate_cmd_buffer(). Fixes: 876c9d3 ("[PATCH] Marvell Libertas 8388 802.11b/g USB driver") Signed-off-by: Zhipeng Lu <[email protected]> Signed-off-by: Kalle Valo <[email protected]> Link: https://msgid.link/[email protected] Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit e888c4461e109f7b93c3522afcbbaa5a8fdf29d2) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent e3350e2 commit 4d0fa7a

File tree

1 file changed

+11
-2
lines changed
  • drivers/net/wireless/marvell/libertas

1 file changed

+11
-2
lines changed

drivers/net/wireless/marvell/libertas/cmd.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,16 +1133,25 @@ int lbs_allocate_cmd_buffer(struct lbs_private *priv)
11331133
if (!cmdarray[i].cmdbuf) {
11341134
lbs_deb_host("ALLOC_CMD_BUF: ptempvirtualaddr is NULL\n");
11351135
ret = -1;
1136-
goto done;
1136+
goto free_cmd_array;
11371137
}
11381138
}
11391139

11401140
for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
11411141
init_waitqueue_head(&cmdarray[i].cmdwait_q);
11421142
lbs_cleanup_and_insert_cmd(priv, &cmdarray[i]);
11431143
}
1144-
ret = 0;
1144+
return 0;
11451145

1146+
free_cmd_array:
1147+
for (i = 0; i < LBS_NUM_CMD_BUFFERS; i++) {
1148+
if (cmdarray[i].cmdbuf) {
1149+
kfree(cmdarray[i].cmdbuf);
1150+
cmdarray[i].cmdbuf = NULL;
1151+
}
1152+
}
1153+
kfree(priv->cmd_array);
1154+
priv->cmd_array = NULL;
11461155
done:
11471156
return ret;
11481157
}

0 commit comments

Comments
 (0)