diff mbox series

[v2,1/2] soc: fsl: dpio: cleanup the cpu array on dpaa2_io_down

Message ID 1543922408-22950-2-git-send-email-ioana.ciornei@nxp.com (mailing list archive)
State New, archived
Headers show
Series soc: fsl: dpio: cleanup on the remove path | expand

Commit Message

Ioana Ciornei Dec. 4, 2018, 11:20 a.m. UTC
The dpio_by_cpu array should not contain a reference to a freed dpaa2_io
object. This patch adds the necessary cleanup in dpaa2_io_down.

Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
Changes in v2:
  - none

 drivers/soc/fsl/dpio/dpio-service.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Leo Li Dec. 5, 2018, 5:51 p.m. UTC | #1
On Tue, Dec 4, 2018 at 5:21 AM Ioana Ciornei <ioana.ciornei@nxp.com> wrote:
>
> The dpio_by_cpu array should not contain a reference to a freed dpaa2_io
> object. This patch adds the necessary cleanup in dpaa2_io_down.

Applied.  Thanks.

>
> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
> ---
> Changes in v2:
>   - none
>
>  drivers/soc/fsl/dpio/dpio-service.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
> index 9b17f72..21c3e32 100644
> --- a/drivers/soc/fsl/dpio/dpio-service.c
> +++ b/drivers/soc/fsl/dpio/dpio-service.c
> @@ -160,6 +160,11 @@ struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc)
>   */
>  void dpaa2_io_down(struct dpaa2_io *d)
>  {
> +       spin_lock(&dpio_list_lock);
> +       dpio_by_cpu[d->dpio_desc.cpu] = NULL;
> +       list_del(&d->node);
> +       spin_unlock(&dpio_list_lock);
> +
>         kfree(d);
>  }
>
> --
> 1.9.1
>
diff mbox series

Patch

diff --git a/drivers/soc/fsl/dpio/dpio-service.c b/drivers/soc/fsl/dpio/dpio-service.c
index 9b17f72..21c3e32 100644
--- a/drivers/soc/fsl/dpio/dpio-service.c
+++ b/drivers/soc/fsl/dpio/dpio-service.c
@@ -160,6 +160,11 @@  struct dpaa2_io *dpaa2_io_create(const struct dpaa2_io_desc *desc)
  */
 void dpaa2_io_down(struct dpaa2_io *d)
 {
+	spin_lock(&dpio_list_lock);
+	dpio_by_cpu[d->dpio_desc.cpu] = NULL;
+	list_del(&d->node);
+	spin_unlock(&dpio_list_lock);
+
 	kfree(d);
 }