]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
PCI/VGA: Pass vga_get_uninterruptible() errors to userspace
authorSimon Richter <Simon.Richter@hogyros.de>
Sat, 7 Mar 2026 17:35:34 +0000 (02:35 +0900)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 25 Mar 2026 18:23:13 +0000 (13:23 -0500)
If VGA routing cannot be established, vga_get_uninterruptible() returns an
error and does not increment the lock count. Return the error to the
caller.

Return before incrementing uc->io_cnt/mem_cnt so vga_arb_release() won't
call vga_put() when userspace closes the handle.

Signed-off-by: Simon Richter <Simon.Richter@hogyros.de>
[bhelgaas: commit log]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/20260307173538.763188-2-Simon.Richter@hogyros.de
drivers/pci/vgaarb.c

index d9383bf541e7c6fb56e348713c610a0a7f1a0664..22b2b6ebdefdb1e0d34a4b9603ccb8d824753a48 100644 (file)
@@ -1134,6 +1134,7 @@ static ssize_t vga_arb_write(struct file *file, const char __user *buf,
        char kbuf[64], *curr_pos;
        size_t remaining = count;
 
+       int err;
        int ret_val;
        int i;
 
@@ -1165,7 +1166,11 @@ static ssize_t vga_arb_write(struct file *file, const char __user *buf,
                        goto done;
                }
 
-               vga_get_uninterruptible(pdev, io_state);
+               err = vga_get_uninterruptible(pdev, io_state);
+               if (err) {
+                       ret_val = err;
+                       goto done;
+               }
 
                /* Update the client's locks lists */
                for (i = 0; i < MAX_USER_CARDS; i++) {