Skip to content

Commit 4fad22a

Browse files
Yuan CanPaolo Abeni
authored andcommitted
dpaa2-switch: Fix memory leak in dpaa2_switch_acl_entry_add() and dpaa2_switch_acl_entry_remove()
The cmd_buff needs to be freed when error happened in dpaa2_switch_acl_entry_add() and dpaa2_switch_acl_entry_remove(). Fixes: 1110318 ("dpaa2-switch: add tc flower hardware offload on ingress traffic") Signed-off-by: Yuan Can <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent 063a932 commit 4fad22a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-switch-flower.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ int dpaa2_switch_acl_entry_add(struct dpaa2_switch_filter_block *filter_block,
132132
DMA_TO_DEVICE);
133133
if (unlikely(dma_mapping_error(dev, acl_entry_cfg->key_iova))) {
134134
dev_err(dev, "DMA mapping failed\n");
135+
kfree(cmd_buff);
135136
return -EFAULT;
136137
}
137138

@@ -142,6 +143,7 @@ int dpaa2_switch_acl_entry_add(struct dpaa2_switch_filter_block *filter_block,
142143
DMA_TO_DEVICE);
143144
if (err) {
144145
dev_err(dev, "dpsw_acl_add_entry() failed %d\n", err);
146+
kfree(cmd_buff);
145147
return err;
146148
}
147149

@@ -172,6 +174,7 @@ dpaa2_switch_acl_entry_remove(struct dpaa2_switch_filter_block *block,
172174
DMA_TO_DEVICE);
173175
if (unlikely(dma_mapping_error(dev, acl_entry_cfg->key_iova))) {
174176
dev_err(dev, "DMA mapping failed\n");
177+
kfree(cmd_buff);
175178
return -EFAULT;
176179
}
177180

@@ -182,6 +185,7 @@ dpaa2_switch_acl_entry_remove(struct dpaa2_switch_filter_block *block,
182185
DMA_TO_DEVICE);
183186
if (err) {
184187
dev_err(dev, "dpsw_acl_remove_entry() failed %d\n", err);
188+
kfree(cmd_buff);
185189
return err;
186190
}
187191

0 commit comments

Comments
 (0)