drivers/mailbox/mailbox.c:543 mbox_free_channel() warn: variable dereferenced before check 'chan' (see line 540)
PATCH 1/1 drivers/mailbox/mailbox.c:543 mbox_free_channel() warn: variable dereferenced before check 'chan' (see line 540)
tree: https://github.com/ambarus/linux-0day mailbox-request-v1 head: 1f2e24358cc2d39e5a26ef0a6b0fe65920f04caf commit: 1f2e24358cc2d39e5a26ef0a6b0fe65920f04caf [1/1] maybox: add simple async mechanism to empower controllers config: sparc64-randconfig-r073-20241005 (https://download.01.org/0day-ci/archive/20241006/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 14.1.0
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/
smatch warnings:drivers/mailbox/mailbox.c:543 mbox_free_channel() warn: variable dereferenced before check 'chan' (see line 540)
vim +/chan +543 drivers/mailbox/mailbox.c
2b6d83e2b8b7de Jassi Brar 2014-06-12 538 void mbox_free_channel(struct mbox_chan *chan)
2b6d83e2b8b7de Jassi Brar 2014-06-12 539 {
1f2e24358cc2d3 Tudor Ambarus 2024-10-03 @540 struct mbox_controller *mbox = chan->mbox;
^^^^^^Dereference
2b6d83e2b8b7de Jassi Brar 2014-06-12 541 unsigned long flags;
2b6d83e2b8b7de Jassi Brar 2014-06-12 542
2b6d83e2b8b7de Jassi Brar 2014-06-12 @543 if (!chan || !chan->cl)
^^^^Checked too late
2b6d83e2b8b7de Jassi Brar 2014-06-12 544 return; 2b6d83e2b8b7de Jassi Brar 2014-06-12 545 1f2e24358cc2d3 Tudor Ambarus 2024-10-03 546 if (mbox->ops->shutdown) 1f2e24358cc2d3 Tudor Ambarus 2024-10-03 547 mbox->ops->shutdown(chan); 1f2e24358cc2d3 Tudor Ambarus 2024-10-03 548 1f2e24358cc2d3 Tudor Ambarus 2024-10-03 549 if (mbox->ops->send_request) 1f2e24358cc2d3 Tudor Ambarus 2024-10-03 550 return module_put(mbox->dev->driver->owner); 2b6d83e2b8b7de Jassi Brar 2014-06-12 551 2b6d83e2b8b7de Jassi Brar 2014-06-12 552 /* The queued TX requests are simply aborted, no callbacks are made */ 2b6d83e2b8b7de Jassi Brar 2014-06-12 553 spin_lock_irqsave(&chan->lock, flags); 2b6d83e2b8b7de Jassi Brar 2014-06-12 554 chan->cl = NULL; 2b6d83e2b8b7de Jassi Brar 2014-06-12 555 chan->active_req = NULL; 33cd7123ac0ba5 Sudeep Holla 2017-09-28 556 if (chan->txdone_method == TXDONE_BY_ACK) 2b6d83e2b8b7de Jassi Brar 2014-06-12 557 chan->txdone_method = TXDONE_BY_POLL; 2b6d83e2b8b7de Jassi Brar 2014-06-12 558 1f2e24358cc2d3 Tudor Ambarus 2024-10-03 559 module_put(mbox->dev->driver->owner); 2b6d83e2b8b7de Jassi Brar 2014-06-12 560 spin_unlock_irqrestore(&chan->lock, flags); 2b6d83e2b8b7de Jassi Brar 2014-06-12 561 }
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 21 lines · Dan Carpenter
tree: https://github.com/ambarus/linux-0day mailbox-request-v1 head: 1f2e24358cc2d39e5a26ef0a6b0fe65920f04caf commit: 1f2e24358cc2d39e5a26ef0a6b0fe65920f04caf [1/1] maybox: add simple async mechanism to empower controllers config: sparc64-randconfig-r073-20241005 (https://download.01.org/0day-ci/archive/20241006/[email protected]/config) compiler: sparc64-linux-gcc (GCC) 14.1.0If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]> | Reported-by: Dan Carpenter <[email protected]> | Closes: https://lore.kernel.org/r/[email protected]/smatch warnings:
drivers/mailbox/mailbox.c:543mbox_free_channel()warn: variable dereferenced before check 'chan' (see line 540)vim +/chan +543
drivers/mailbox/mailbox.c2b6d83e2b8b7de Jassi Brar 2014-06-12 538 void mbox_free_channel(struct mbox_chan *chan) 2b6d83e2b8b7de Jassi Brar 2014-06-12 539 { 1f2e24358cc2d3 Tudor Ambarus 2024-10-03 @540 struct mbox_controller *mbox = chan->mbox; ^^^^^^
Quoted 7 lines
Dereference
2b6d83e2b8b7de Jassi Brar 2014-06-12 541 unsigned long flags; 2b6d83e2b8b7de Jassi Brar 2014-06-12 542 2b6d83e2b8b7de Jassi Brar 2014-06-12 @543 if (!chan || !chan->cl) ^^^^Checked too late
oh, yes, thanks. I'll fix it in v2. cheers.