All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jinpu Wang <jinpu.wang@ionos.com>
To: Ajish Koshy <Ajish.Koshy@microchip.com>
Cc: Linux SCSI Mailinglist <linux-scsi@vger.kernel.org>,
	Vasanthalakshmi.Tharmarajan@microchip.com,
	Viswas G <Viswas.G@microchip.com>,
	Ruksar Devadi <Ruksar.devadi@microchip.com>,
	Ashokkumar N <Ashokkumar.N@microchip.com>,
	Jinpu Wang <jinpu.wang@cloud.ionos.com>
Subject: Re: [PATCH 4/4] scsi: pm80xx: fix memory leak during rmmod
Date: Mon, 30 Aug 2021 10:25:03 +0200	[thread overview]
Message-ID: <CAMGffEmzYfp9BjDpjfckPwjGwreAtD9sz7u5fr+h7XJYpbkJRg@mail.gmail.com> (raw)
In-Reply-To: <20210823082338.67309-5-Ajish.Koshy@microchip.com>

On Mon, Aug 23, 2021 at 9:28 AM Ajish Koshy <Ajish.Koshy@microchip.com> wrote:
>
> Driver fails to release memory allocated. This will lead
> to memory leak during driver removal.
>
> Signed-off-by: Ajish Koshy <Ajish.Koshy@microchip.com>
> Signed-off-by: Viswas G <Viswas.G@microchip.com>
looks ok.
Acked-by: Jack Wang <jinpu.wang@ionos.com>
> ---
>  drivers/scsi/pm8001/pm8001_init.c | 11 +++++++++++
>  drivers/scsi/pm8001/pm8001_sas.h  |  1 +
>  2 files changed, 12 insertions(+)
>
> diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
> index 613455a3e686..7082fecf7ce8 100644
> --- a/drivers/scsi/pm8001/pm8001_init.c
> +++ b/drivers/scsi/pm8001/pm8001_init.c
> @@ -1199,6 +1199,7 @@ pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost,
>                 goto err_out;
>
>         /* Memory region for ccb_info*/
> +       pm8001_ha->ccb_count = ccb_count;
>         pm8001_ha->ccb_info =
>                 kcalloc(ccb_count, sizeof(struct pm8001_ccb_info), GFP_KERNEL);
>         if (!pm8001_ha->ccb_info) {
> @@ -1260,6 +1261,16 @@ static void pm8001_pci_remove(struct pci_dev *pdev)
>                         tasklet_kill(&pm8001_ha->tasklet[j]);
>  #endif
>         scsi_host_put(pm8001_ha->shost);
> +
> +       for (i = 0; i < pm8001_ha->ccb_count; i++) {
> +               dma_free_coherent(&pm8001_ha->pdev->dev,
> +                       sizeof(struct pm8001_prd) * PM8001_MAX_DMA_SG,
> +                       pm8001_ha->ccb_info[i].buf_prd,
> +                       pm8001_ha->ccb_info[i].ccb_dma_handle);
> +       }
> +       kfree(pm8001_ha->ccb_info);
> +       kfree(pm8001_ha->devices);
> +
>         pm8001_free(pm8001_ha);
>         kfree(sha->sas_phy);
>         kfree(sha->sas_port);
> diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
> index 3274d88a9ccc..7e999768bfd2 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.h
> +++ b/drivers/scsi/pm8001/pm8001_sas.h
> @@ -518,6 +518,7 @@ struct pm8001_hba_info {
>         u32                     iomb_size; /* SPC and SPCV IOMB size */
>         struct pm8001_device    *devices;
>         struct pm8001_ccb_info  *ccb_info;
> +       u32                     ccb_count;
>  #ifdef PM8001_USE_MSIX
>         int                     number_of_intr;/*will be used in remove()*/
>         char                    intr_drvname[PM8001_MAX_MSIX_VEC]
> --
> 2.27.0
>

      reply	other threads:[~2021-08-30  8:25 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23  8:23 [PATCH 0/4] pm80xx updates Ajish Koshy
2021-08-23  8:23 ` [PATCH 1/4] scsi: pm80xx: fix incorrect port value when registering a device Ajish Koshy
2021-08-30  7:58   ` Jinpu Wang
2021-09-01 11:44     ` Ajish.Koshy
2021-08-23  8:23 ` [PATCH 2/4] scsi: pm80xx: fix lockup due to commit <1f02beff224e> Ajish Koshy
2021-08-30  8:22   ` Jinpu Wang
2021-09-01 11:55     ` Ajish.Koshy
2021-08-23  8:23 ` [PATCH 3/4] scsi: pm80xx: Corrected Inbound and Outbound queue logging Ajish Koshy
2021-08-30  8:23   ` Jinpu Wang
2021-08-23  8:23 ` [PATCH 4/4] scsi: pm80xx: fix memory leak during rmmod Ajish Koshy
2021-08-30  8:25   ` Jinpu Wang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAMGffEmzYfp9BjDpjfckPwjGwreAtD9sz7u5fr+h7XJYpbkJRg@mail.gmail.com \
    --to=jinpu.wang@ionos.com \
    --cc=Ajish.Koshy@microchip.com \
    --cc=Ashokkumar.N@microchip.com \
    --cc=Ruksar.devadi@microchip.com \
    --cc=Vasanthalakshmi.Tharmarajan@microchip.com \
    --cc=Viswas.G@microchip.com \
    --cc=jinpu.wang@cloud.ionos.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.