mailbox: cix: validate channel parameters early and convert to dev_err_probe
Subsystems (2)
PATCH 1/1 mailbox: cix: validate channel parameters early and convert to dev_err_probe
From: Surendra Singh Chouhan <[email protected]>
cix_mbox_startup() checked fast channel index constraints (index < 0 || index > CIX_MBOX_FAST_IDX) inside the channel switch block after calling request_irq(). If validation failed, it triggered a free_irq() cleanup path. Validating channel parameters prior to request_irq() avoids unnecessary IRQ registration/teardown churn.
In addition, cix_mbox_probe() logged property errors referencing "cix,mbox_dir" (with an underscore) instead of the actual DT property name "cix,mbox-dir". Convert cix_mbox_probe() error paths to use dev_err_probe() and fix the DT property string spelling.
--- drivers/mailbox/cix-mailbox.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
drivers/mailbox/cix-mailbox.c +16 -15
@@ -403,6 +403,13 @@ static int cix_mbox_startup(struct mbox_chan *chan)int index = cp->index, ret;u32 val; +if (cp->type ==CIX_MBOX_TYPE_FAST && priv->dir ==CIX_MBOX_RX ) { +if (index <0 || index >CIX_MBOX_FAST_IDX ) { +dev_err (priv->dev,"Invalid index %d\n" , index); +return -EINVAL ; + } + } + ret =request_irq (priv->irq, cix_mbox_isr,IRQF_NO_SUSPEND ,dev_name (priv->dev), chan);if (ret) {
@@ -448,11 +455,6 @@ static int cix_mbox_startup(struct mbox_chan *chan)case CIX_MBOX_TYPE_FAST :/* Only RX channel has intterupt */ if (priv->dir ==CIX_MBOX_RX ) { -if (index <0 || index >CIX_MBOX_FAST_IDX ) { -dev_err (priv->dev,"Invalid index %d\n" , index); - ret = -EINVAL ; - goto failed; - }/* enable fast channel interrupt */ val =cix_mbox_read (priv,CIX_INT_ENABLE_SIDE_B ); val |=CIX_FAST_CH_INT (index);
@@ -587,19 +589,18 @@ static int cix_mbox_probe(struct platform_device *pdev)if (priv->irq <0 )return priv->irq; -if (device_property_read_string (dev,"cix,mbox-dir" , &dir_str)) { -dev_err (priv->dev,"cix,mbox_dir property not found\n" ); -return -EINVAL ; - } +if (device_property_read_string (dev,"cix,mbox-dir" , &dir_str)) +return dev_err_probe (dev, -EINVAL , +"cix,mbox-dir property not found\n" );if (!strcmp (dir_str,"tx" )) priv->dir =0 ;else if (!strcmp (dir_str,"rx" )) priv->dir =1 ; -else { -dev_err (priv->dev,"cix,mbox_dir=%s is not expected\n" , dir_str); -return -EINVAL ; - } +else +return dev_err_probe (dev, -EINVAL , +"cix,mbox-dir=%s is not expected\n" , + dir_str);cix_mbox_init (priv);
@@ -613,9 +614,9 @@ static int cix_mbox_probe(struct platform_device *pdev)platform_set_drvdata (pdev, priv); ret =devm_mbox_controller_register (dev, &priv->mbox);if (ret) -dev_err (dev,"Failed to register mailbox %d\n" , ret); +return dev_err_probe (dev, ret,"Failed to register mailbox\n" ); -return ret; +return 0 ; }static const struct of_device_id cix_mbox_dt_ids[] = {
Signature · 1 line
2.55.0
Jassi Brar
maintainerQuoted 9 lines · On Fri, Jul 24, 2026 at 1:42 AM <[email protected]> wrote:
From: Surendra Singh Chouhan <[email protected]>
cix_mbox_startup()checked fast channel index constraints (index < 0 || index >CIX_MBOX_FAST_IDX) inside the channel switch block after callingrequest_irq(). If validation failed, it triggered afree_irq()cleanup path. Validating channel parameters prior torequest_irq()avoids unnecessary IRQ registration/teardown churn.
Quoted 5 lines
In addition,
cix_mbox_probe()logged property errors referencing "cix,mbox_dir" (with an underscore) instead of the actual DT property name "cix,mbox-dir". Convertcix_mbox_probe()error paths to usedev_err_probe()and fix the DT property string spelling.
These should be two patches.
Thanks
Jassi