From cebcd751ed0330235cf833a41460a6b9f48efb8c Mon Sep 17 00:00:00 2001 From: Shaun Ruffell Date: Sat, 3 Apr 2010 17:50:28 +0000 Subject: wcte12xp, wctdm24xxp: Close a memory leak when processing VPM commands. Closes a memory leak when processing the VPM write commands introduced in r8454. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8460 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- drivers/dahdi/voicebus/GpakCust.h | 7 ++++++- drivers/dahdi/wctdm24xxp/base.c | 5 ++++- drivers/dahdi/wcte12xp/base.c | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/dahdi/voicebus/GpakCust.h b/drivers/dahdi/voicebus/GpakCust.h index 549922e..3842156 100644 --- a/drivers/dahdi/voicebus/GpakCust.h +++ b/drivers/dahdi/voicebus/GpakCust.h @@ -149,6 +149,11 @@ void vpmadt032_echocan_free(struct vpmadt032 *vpm, int channo, struct GpakEcanParms; void vpmadt032_get_default_parameters(struct GpakEcanParms *p); +static inline int is_cmd_write(const struct vpmadt032_cmd *cmd) +{ + return (cmd->desc & __VPM150M_WR) != 0; +} + /* If there is a command ready to go to the VPMADT032, return it, otherwise NULL */ static inline struct vpmadt032_cmd *vpmadt032_get_ready_cmd(struct vpmadt032 *vpm) { @@ -161,7 +166,7 @@ static inline struct vpmadt032_cmd *vpmadt032_get_ready_cmd(struct vpmadt032 *vp return NULL; } cmd = list_entry(vpm->pending_cmds.next, struct vpmadt032_cmd, node); - if (cmd->desc & __VPM150M_WR) + if (!is_cmd_write(cmd)) list_move_tail(&cmd->node, &vpm->active_cmds); else list_del_init(&cmd->node); diff --git a/drivers/dahdi/wctdm24xxp/base.c b/drivers/dahdi/wctdm24xxp/base.c index 59ec4be..e55c53b 100644 --- a/drivers/dahdi/wctdm24xxp/base.c +++ b/drivers/dahdi/wctdm24xxp/base.c @@ -592,6 +592,9 @@ static inline void cmd_dequeue_vpmadt032(struct wctdm *wc, u8 *writechunk, int w writechunk[CMD_BYTE(27, 1, 0)] = 0; writechunk[CMD_BYTE(27, 2, 0)] = 0; } + if (is_cmd_write(curcmd)) + kfree(curcmd); + } else if (test_and_clear_bit(VPM150M_SWRESET, &vpmadt032->control)) { for (x = 24; x < 28; x++) { if (x == 24) @@ -785,7 +788,7 @@ static inline void cmd_decipher_vpmadt032(struct wctdm *wc, const u8 *readchunk) cmd->data = (0xff & readchunk[CMD_BYTE(25, 1, 0)]) << 8; cmd->data |= readchunk[CMD_BYTE(25, 2, 0)]; if (cmd->desc & __VPM150M_WR) { - kfree(&cmd->node); + kfree(cmd); } else { cmd->desc |= __VPM150M_FIN; complete(&cmd->complete); diff --git a/drivers/dahdi/wcte12xp/base.c b/drivers/dahdi/wcte12xp/base.c index a1f1c42..7645634 100644 --- a/drivers/dahdi/wcte12xp/base.c +++ b/drivers/dahdi/wcte12xp/base.c @@ -259,7 +259,7 @@ inline void cmd_decipher_vpmadt032(struct t1 *wc, const u8 *readchunk) cmd->data = (0xff & readchunk[CMD_BYTE(2, 1, 1)]) << 8; cmd->data |= readchunk[CMD_BYTE(2, 2, 1)]; if (cmd->desc & __VPM150M_WR) { - kfree(&cmd->node); + kfree(cmd); } else { cmd->desc |= __VPM150M_FIN; complete(&cmd->complete); @@ -503,6 +503,9 @@ static void cmd_dequeue_vpmadt032(struct t1 *wc, unsigned char *writechunk, int writechunk[CMD_BYTE(4, 1, 1)] = 0; writechunk[CMD_BYTE(4, 2, 1)] = 0; } + if (is_cmd_write(cmd)) + kfree(cmd); + } else if (test_and_clear_bit(VPM150M_SWRESET, &vpm->control)) { for (x = 0; x < 7; x++) { if (0 == x) { -- cgit v1.2.3