Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "WenTao Liang" <vulab@iscas.ac.cn>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH] scsi: esas2r: fix refcount leak in esas2r_resume()
Date: Thu, 11 Jun 2026 06:53:35 +0000	[thread overview]
Message-ID: <20260611065336.448941F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611064100.65731-1-vulab@iscas.ac.cn>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch introduces a critical vulnerability in the IRQ claim failure path by blindly calling `esas2r_enable_chip_interrupts()`. Since `esas2r_power_up()` already decremented the `dis_ints_cnt` refcount on its success path, this additional call drops the refcount to 0, which physically unmasks hardware interrupts without a registered OS-level handler.
--

commit bcbf85bebac19683b875da8be0ef4e9cf5ebfcdd
Author: WenTao Liang <vulab@iscas.ac.cn>

scsi: esas2r: fix refcount leak in esas2r_resume()

This commit attempts to fix a refcount leak in esas2r_resume() by calling
esas2r_enable_chip_interrupts() on the error paths.

> diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c
> index 0a35f19537680..727ddcebec9f9 100644
> --- a/drivers/scsi/esas2r/esas2r_init.c
> +++ b/drivers/scsi/esas2r/esas2r_init.c

[ ... ]

> @@ -699,6 +700,7 @@ static int __maybe_unused esas2r_resume(struct device *dev)
>  		esas2r_debug("yikes, unable to claim IRQ");
>  		esas2r_log(ESAS2R_LOG_CRIT, "could not re-claim IRQ!");
>  		rez = -ENOMEM;
> +		esas2r_enable_chip_interrupts(a);

[Severity: High]
Does this call to esas2r_enable_chip_interrupts() prematurely drop the
dis_ints_cnt refcount to 0 and physically unmask hardware interrupts?

If esas2r_power_up() succeeded earlier in this function, its internal success
path already decremented the dis_ints_cnt refcount back to 1.

If esas2r_claim_interrupts() subsequently fails to register an IRQ handler and
execution branches to this error path, calling esas2r_enable_chip_interrupts()
again drops the refcount from 1 to 0.

When the counter reaches 0, it writes ESAS2R_INT_ENB_MASK to the hardware
register to unmask interrupts. Since the OS explicitly refused to grant the
IRQ, will any generated hardware interrupt be left unhandled, leading to a
screaming interrupt on shared lines and forcing the kernel to disable the
shared IRQ line?

>  		goto error_exit;
>  	}
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260611064100.65731-1-vulab@iscas.ac.cn?part=1

      reply	other threads:[~2026-06-11  6:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-11  6:41 [PATCH] scsi: esas2r: fix refcount leak in esas2r_resume() WenTao Liang
2026-06-11  6:53 ` sashiko-bot [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=20260611065336.448941F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vulab@iscas.ac.cn \
    /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