All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: vkoul@kernel.org
Cc: alsa-devel@alsa-project.org
Subject: [bug report] ASoC: Intel: mrfld - create separate module for pci part
Date: Fri, 3 Dec 2021 13:13:54 +0300	[thread overview]
Message-ID: <20211202151322.GA21325@kili> (raw)

Hello Vinod Koul,

The patch f533a035e4da: "ASoC: Intel: mrfld - create separate module
for pci part" from Nov 4, 2014, leads to the following Smatch static
checker warning:

	sound/soc/intel/atom/sst/sst_pci.c:102 sst_platform_get_resources()
	warn: resource freed on success: 'ctx->pci'

sound/soc/intel/atom/sst/sst_pci.c
    25 static int sst_platform_get_resources(struct intel_sst_drv *ctx)
    26 {
    27         int ddr_base, ret = 0;
    28         struct pci_dev *pci = ctx->pci;
    29 
    30         ret = pci_request_regions(pci, SST_DRV_NAME);
    31         if (ret)
    32                 return ret;
    33 
    34         /* map registers */
    35         /* DDR base */
    36         if (ctx->dev_id == SST_MRFLD_PCI_ID) {
    37                 ctx->ddr_base = pci_resource_start(pci, 0);
    38                 /* check that the relocated IMR base matches with FW Binary */
    39                 ddr_base = relocate_imr_addr_mrfld(ctx->ddr_base);
    40                 if (!ctx->pdata->lib_info) {
    41                         dev_err(ctx->dev, "lib_info pointer NULL\n");
    42                         ret = -EINVAL;
    43                         goto do_release_regions;
    44                 }
    45                 if (ddr_base != ctx->pdata->lib_info->mod_base) {
    46                         dev_err(ctx->dev,
    47                                         "FW LSP DDR BASE does not match with IFWI\n");
    48                         ret = -EINVAL;
    49                         goto do_release_regions;
    50                 }
    51                 ctx->ddr_end = pci_resource_end(pci, 0);
    52 
    53                 ctx->ddr = pcim_iomap(pci, 0,
    54                                         pci_resource_len(pci, 0));
    55                 if (!ctx->ddr) {
    56                         ret = -EINVAL;
    57                         goto do_release_regions;
    58                 }
    59                 dev_dbg(ctx->dev, "sst: DDR Ptr %p\n", ctx->ddr);
    60         } else {
    61                 ctx->ddr = NULL;
    62         }
    63         /* SHIM */
    64         ctx->shim_phy_add = pci_resource_start(pci, 1);
    65         ctx->shim = pcim_iomap(pci, 1, pci_resource_len(pci, 1));
    66         if (!ctx->shim) {
    67                 ret = -EINVAL;
    68                 goto do_release_regions;
    69         }
    70         dev_dbg(ctx->dev, "SST Shim Ptr %p\n", ctx->shim);
    71 
    72         /* Shared SRAM */
    73         ctx->mailbox_add = pci_resource_start(pci, 2);
    74         ctx->mailbox = pcim_iomap(pci, 2, pci_resource_len(pci, 2));
    75         if (!ctx->mailbox) {
    76                 ret = -EINVAL;
    77                 goto do_release_regions;
    78         }
    79         dev_dbg(ctx->dev, "SRAM Ptr %p\n", ctx->mailbox);
    80 
    81         /* IRAM */
    82         ctx->iram_end = pci_resource_end(pci, 3);
    83         ctx->iram_base = pci_resource_start(pci, 3);
    84         ctx->iram = pcim_iomap(pci, 3, pci_resource_len(pci, 3));
    85         if (!ctx->iram) {
    86                 ret = -EINVAL;
    87                 goto do_release_regions;
    88         }
    89         dev_dbg(ctx->dev, "IRAM Ptr %p\n", ctx->iram);
    90 
    91         /* DRAM */
    92         ctx->dram_end = pci_resource_end(pci, 4);
    93         ctx->dram_base = pci_resource_start(pci, 4);
    94         ctx->dram = pcim_iomap(pci, 4, pci_resource_len(pci, 4));
    95         if (!ctx->dram) {
    96                 ret = -EINVAL;
    97                 goto do_release_regions;
    98         }
    99         dev_dbg(ctx->dev, "DRAM Ptr %p\n", ctx->dram);
    100 do_release_regions:
    101         pci_release_regions(pci);
--> 102         return ret;
    103 }

Surely there should be a "return 0;" before the do_release_regions:
label?  How does this code work?

regards,
dan carpenter

             reply	other threads:[~2021-12-03 10:16 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-03 10:13 Dan Carpenter [this message]
2021-12-03 13:46 ` [bug report] ASoC: Intel: mrfld - create separate module for pci part Pierre-Louis Bossart
2021-12-03 18:42   ` Mark Brown
2021-12-03 20:37   ` Andy Shevchenko
2021-12-03 20:41     ` Andy Shevchenko
2021-12-03 22:58       ` Pierre-Louis Bossart
2021-12-03 23:33         ` Ferry Toth
2021-12-03 20:39   ` Andy Shevchenko
2021-12-04 13:50   ` Hans de Goede

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=20211202151322.GA21325@kili \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=vkoul@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.