public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: Zheyu Ma <zheyuma97@gmail.com>,
	lgirdwood@gmail.com, ranjani.sridharan@linux.intel.com,
	kai.vehmanen@linux.intel.com, broonie@kernel.org, perex@perex.cz,
	tiwai@suse.com, peter.ujfalusi@linux.intel.com
Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	sound-open-firmware@alsa-project.org
Subject: Re: [PATCH] ASoC: SOF: Intel: Check the bar size before remapping
Date: Mon, 11 Apr 2022 10:28:11 -0500	[thread overview]
Message-ID: <18cb711a-de2a-69e3-d753-7012a67bf2a7@linux.intel.com> (raw)
In-Reply-To: <20220409143950.2570186-1-zheyuma97@gmail.com>



On 4/9/22 09:39, Zheyu Ma wrote:
> The driver should use the pci_resource_len() to get the actual length of
> pci bar, and compare it with the expect value. If the bar size is too
> small (such as a broken device), the driver should return an error.
> 
> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
> ---
>  sound/soc/sof/intel/pci-tng.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/sound/soc/sof/intel/pci-tng.c b/sound/soc/sof/intel/pci-tng.c
> index 6efef225973f..7d502cc3ca80 100644
> --- a/sound/soc/sof/intel/pci-tng.c
> +++ b/sound/soc/sof/intel/pci-tng.c
> @@ -75,7 +75,11 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)
>  
>  	/* LPE base */
>  	base = pci_resource_start(pci, desc->resindex_lpe_base) - IRAM_OFFSET;
> -	size = PCI_BAR_SIZE;
> +	size = pci_resource_len(pci, desc->resindex_lpe_base);
> +	if (size < PCI_BAR_SIZE) {
> +		dev_err(sdev->dev, "error: I/O region is too small.\n");
> +		return -ENODEV;
> +	}

May I ask how you found this issue?

I am not clear on why there's a patch dedicated for a single device, but the same pattern in hda.c and in the HDaudio legacy driver exists.

>  
>  	dev_dbg(sdev->dev, "LPE PHY base at 0x%x size 0x%x", base, size);
>  	sdev->bar[DSP_BAR] = devm_ioremap(sdev->dev, base, size);

  reply	other threads:[~2022-04-11 16:23 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-09 14:39 [PATCH] ASoC: SOF: Intel: Check the bar size before remapping Zheyu Ma
2022-04-11 15:28 ` Pierre-Louis Bossart [this message]
2022-04-12  1:55   ` Zheyu Ma
2022-04-13 17:36 ` Mark Brown

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=18cb711a-de2a-69e3-d753-7012a67bf2a7@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=sound-open-firmware@alsa-project.org \
    --cc=tiwai@suse.com \
    --cc=zheyuma97@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox