Linux PCI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Hui Peng" <benquike@gmail.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH v2 1/2] PCI/VGA: fix inverted vga_tryget() return check in vga_arb_write()
Date: Mon, 21 Sep 2026 05:36:41 +0000	[thread overview]
Message-ID: <20260921053642.106671F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260921052702.1725696-1-benquike@gmail.com>

> In vga_arb_write(), the "trylock" command handler calls
> vga_tryget(pdev, io_state) and checks:
> 
>   if (vga_tryget(pdev, io_state)) {
>       /* Update the client's locks lists... */
> 
> However, vga_tryget() returns 0 on success and a negative errno (-EBUSY)
> when the VGA resources are already locked. Because the check tests for a
> non-zero return value, a successful vga_tryget() skips incrementing
> priv->cards[i].io_cnt / mem_cnt and skips reporting success, leaking the
> acquired VGA lock, whereas a failed vga_tryget() (-EBUSY) erroneously
> records the lock in priv->cards[i] so a subsequent "unlock" or file
> release decrements the lock count without holding the lock.
> 
> Check if (vga_tryget(pdev, io_state) == 0) in vga_arb_write().
> 
> Tested in QEMU against Linux 7.3.0-rc3 by opening /dev/vga_arbiter and
> writing "trylock io+mem" followed by closing the file descriptor. On the
> unfixed kernel, write("trylock io+mem") acquires the VGA lock
> (locks=io+mem(1:1)) but takes the error branch and returns -EBUSY (-16)
> without recording the lock in priv->cards[], permanently leaking the
> lock on close(); with this patch applied, write("trylock io+mem")
> succeeds (ret = 14) and close() cleanly releases the lock
> (locks=none(0:0)).
> 
> Fixes: deb2d2ecd43d ("PCI/GPU: implement VGA arbitration on Linux")
> Cc: stable@vger.kernel.org
> Assisted-by: LLM
> Signed-off-by: Hui Peng <benquike@gmail.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260921052702.1725696-1-benquike@gmail.com?part=1


  parent reply	other threads:[~2026-09-21  5:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-19 22:26 [PATCH] PCI/VGA: fix inverted vga_tryget() return check and clear removed pci_dev Hui Peng
2026-09-19 22:48 ` sashiko-bot
2026-09-21  5:27 ` [PATCH v2 1/2] PCI/VGA: fix inverted vga_tryget() return check in vga_arb_write() Hui Peng
2026-09-21  5:27   ` [PATCH v2 2/2] PCI/VGA: invalidate open user references in vga_arbiter_del_pci_device() Hui Peng
2026-09-21  5:38     ` sashiko-bot
2026-09-21  5:36   ` sashiko-bot [this message]
2026-09-21 10:39 ` [PATCH] PCI/VGA: fix inverted vga_tryget() return check and clear removed pci_dev Jani Nikula
2026-09-21 15:09 ` krzk

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=20260921053642.106671F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=benquike@gmail.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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