Linux Media Controller development
 help / color / mirror / Atom feed
From: Sakari Ailus <sakari.ailus@linux.intel.com>
To: Myeonghun Pak <mhun512@gmail.com>
Cc: Yong Zhi <yong.zhi@intel.com>, Bingbu Cao <bingbu.cao@intel.com>,
	Dan Scally <dan.scally@ideasonboard.com>,
	Tianshu Qiu <tian.shu.qiu@intel.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Ijae Kim <ae878000@gmail.com>
Subject: Re: [PATCH] media: ipu3-cio2: disable MSI on probe failure and remove
Date: Wed, 15 Jul 2026 11:23:42 +0300	[thread overview]
Message-ID: <aldDjnZ33ljackNd@kekkonen.localdomain> (raw)
In-Reply-To: <20260715075607.62277-1-mhun512@gmail.com>

Hi Myeonghun,

Thank you for the patch.

On Wed, Jul 15, 2026 at 04:56:07PM +0900, Myeonghun Pak wrote:
> cio2_pci_probe() enables MSI with pci_enable_msi() but pci_disable_msi() is
> never called, so MSI is left enabled on the probe error paths and on normal
> removal in cio2_pci_remove().
> 
> The IRQ is requested with devm_request_irq() and freed by devres only after
> remove() (or a failed probe) returns, so a plain pci_disable_msi() in
> remove() would tear the MSI vector down before free_irq() runs. Register it
> with devm_add_action_or_reset() right after pci_enable_msi() instead: devres
> releases in reverse order, so the IRQ is freed before MSI is disabled, on
> every error path and on remove.
> 
> This issue was identified during our ongoing static-analysis research while
> reviewing kernel code.
> 
> Fixes: c2a6a07afe4a ("media: intel-ipu3: cio2: add new MIPI-CSI2 driver")
> Co-developed-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Ijae Kim <ae878000@gmail.com>
> Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
> ---
>  drivers/media/pci/intel/ipu3/ipu3-cio2.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> index 986b9afd7c..3f738ca681 100644
> --- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> +++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c
> @@ -1654,6 +1654,13 @@ static void cio2_queues_exit(struct cio2_device *cio2)
>  
>  /**************** PCI interface ****************/
>  
> +static void cio2_disable_msi(void *data)
> +{
> +	struct pci_dev *pci_dev = data;
> +
> +	pci_disable_msi(pci_dev);
> +}
> +
>  static int cio2_pci_probe(struct pci_dev *pci_dev,
>  			  const struct pci_device_id *id)
>  {
> @@ -1707,6 +1714,10 @@ static int cio2_pci_probe(struct pci_dev *pci_dev,
>  		return r;
>  	}
>  
> +	r = devm_add_action_or_reset(dev, cio2_disable_msi, pci_dev);

I think I'd do this without using devm_*().

Alternatively, pcim_enable_msi() could be nice. There would probably be
other similar functions that could benefit from similar wrappers so that
might be best kept separate in any case, also for backporting reasons.

> +	if (r)
> +		return r;
> +
>  	r = cio2_fbpt_init_dummy(cio2);
>  	if (r)
>  		return r;

-- 
Kind regards,

Sakari Ailus

      reply	other threads:[~2026-07-15  8:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15  7:56 [PATCH] media: ipu3-cio2: disable MSI on probe failure and remove Myeonghun Pak
2026-07-15  8:23 ` Sakari Ailus [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=aldDjnZ33ljackNd@kekkonen.localdomain \
    --to=sakari.ailus@linux.intel.com \
    --cc=ae878000@gmail.com \
    --cc=bingbu.cao@intel.com \
    --cc=dan.scally@ideasonboard.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=mhun512@gmail.com \
    --cc=tian.shu.qiu@intel.com \
    --cc=yong.zhi@intel.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