PCI/AER: Simplify add_error_device()
authorBjorn Helgaas <bhelgaas@google.com>
Thu, 22 May 2025 23:21:23 +0000 (18:21 -0500)
committerBjorn Helgaas <bhelgaas@google.com>
Fri, 23 May 2025 16:11:45 +0000 (11:11 -0500)
Return -ENOSPC error early so the usual path through add_error_device() is
the straightline code.

Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com>
Link: https://patch.msgid.link/20250522232339.1525671-18-helgaas@kernel.org
drivers/pci/pcie/aer.c

index ab99bc1b8542023ce6e3b20e98d1135356e0356d..5d62b82b5bc1f96729b21e444c38c76956a02b0f 100644 (file)
@@ -816,12 +816,15 @@ EXPORT_SYMBOL_NS_GPL(pci_print_aer, "CXL");
  */
 static int add_error_device(struct aer_err_info *e_info, struct pci_dev *dev)
 {
-       if (e_info->error_dev_num < AER_MAX_MULTI_ERR_DEVICES) {
-               e_info->dev[e_info->error_dev_num] = pci_dev_get(dev);
-               e_info->error_dev_num++;
-               return 0;
-       }
-       return -ENOSPC;
+       int i = e_info->error_dev_num;
+
+       if (i >= AER_MAX_MULTI_ERR_DEVICES)
+               return -ENOSPC;
+
+       e_info->dev[i] = pci_dev_get(dev);
+       e_info->error_dev_num++;
+
+       return 0;
 }
 
 /**