Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] commit message references incorrect functions for vga_tryget() fix
--

commit 341d48fbd447d6890560b76963b8d28bd58bbe29
Author: Hui Peng <[email protected]>

PCI/VGA: fix inverted vga_tryget() return check and clear removed pci_dev

This commit fixes an inverted return check for vga_tryget() and clears open
references pointing to a removed pci_dev in vga_arbiter_del_pci_device()
to prevent dereferencing a freed pci_dev.

>     1. In vga_arb_device_init() / vga_arbiter_From_pci_dev(), vga_tryget()
>        returns 0 on success and a negative errno on failure, so checking if
>        (!vga_tryget(...)) is inverted and skips unlocking on success.

[Severity: Medium]
The commit message references incorrect functions for the vga_tryget() fix.

Reading the commit message suggests looking at vga_arb_device_init() or
vga_arbiter_From_pci_dev() for the vga_tryget() fix. However,
vga_arb_device_init() does not call vga_tryget(), and
vga_arbiter_From_pci_dev() does not exist in the codebase.

The actual code modified to fix the inverted return check is in
vga_arb_write().

Could the commit message be updated to accurately reflect the function
where the fix is applied?

> diff --git a/drivers/pci/vgaarb.c b/drivers/pci/vgaarb.c
> index 3de05aee78599..4f13e542505ad 100644
> --- a/drivers/pci/vgaarb.c
> +++ b/drivers/pci/vgaarb.c
[ ... ]
> @@ -1266,12 +1282,12 @@ static ssize_t vga_arb_write(struct file *file, const 
> char __user *buf,
>                */
>  
>               pdev = priv->target;
> -             if (priv->target == NULL) {
> +             if (priv->target == NULL || priv->target == PCI_INVALID_CARD) {
>                       ret_val = -ENODEV;
>                       goto done;
>               }
>  
> -             if (vga_tryget(pdev, io_state)) {
> +             if (vga_tryget(pdev, io_state) == 0) {
>                       /* Update the client's locks lists... */

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=1

Reply via email to