Merge tag 's390-5.15-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 fixes from Vasily Gorbik:

- Fix potential memory leak on a error path in eBPF

- Fix handling of zpci device on reserve

* tag 's390-5.15-5' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390/pci: fix zpci_zdev_put() on reserve
bpf, s390: Fix potential memory leak about jit_data

+46 -16
+2
arch/s390/include/asm/pci.h
··· 207 207 int zpci_disable_device(struct zpci_dev *); 208 208 int zpci_scan_configured_device(struct zpci_dev *zdev, u32 fh); 209 209 int zpci_deconfigure_device(struct zpci_dev *zdev); 210 + void zpci_device_reserved(struct zpci_dev *zdev); 211 + bool zpci_is_device_configured(struct zpci_dev *zdev); 210 212 211 213 int zpci_register_ioat(struct zpci_dev *, u8, u64, u64, u64); 212 214 int zpci_unregister_ioat(struct zpci_dev *, u8);
+1 -1
arch/s390/net/bpf_jit_comp.c
··· 1826 1826 jit.addrs = kvcalloc(fp->len + 1, sizeof(*jit.addrs), GFP_KERNEL); 1827 1827 if (jit.addrs == NULL) { 1828 1828 fp = orig_fp; 1829 - goto out; 1829 + goto free_addrs; 1830 1830 } 1831 1831 /* 1832 1832 * Three initial passes:
+40 -5
arch/s390/pci/pci.c
··· 92 92 spin_unlock(&zpci_list_lock); 93 93 94 94 list_for_each_entry_safe(zdev, tmp, &remove, entry) 95 - zpci_zdev_put(zdev); 95 + zpci_device_reserved(zdev); 96 96 } 97 97 98 98 int pci_domain_nr(struct pci_bus *bus) ··· 751 751 return ERR_PTR(rc); 752 752 } 753 753 754 + bool zpci_is_device_configured(struct zpci_dev *zdev) 755 + { 756 + enum zpci_state state = zdev->state; 757 + 758 + return state != ZPCI_FN_STATE_RESERVED && 759 + state != ZPCI_FN_STATE_STANDBY; 760 + } 761 + 754 762 /** 755 763 * zpci_scan_configured_device() - Scan a freshly configured zpci_dev 756 764 * @zdev: The zpci_dev to be configured ··· 830 822 return 0; 831 823 } 832 824 825 + /** 826 + * zpci_device_reserved() - Mark device as resverved 827 + * @zdev: the zpci_dev that was reserved 828 + * 829 + * Handle the case that a given zPCI function was reserved by another system. 830 + * After a call to this function the zpci_dev can not be found via 831 + * get_zdev_by_fid() anymore but may still be accessible via existing 832 + * references though it will not be functional anymore. 833 + */ 834 + void zpci_device_reserved(struct zpci_dev *zdev) 835 + { 836 + if (zdev->has_hp_slot) 837 + zpci_exit_slot(zdev); 838 + /* 839 + * Remove device from zpci_list as it is going away. This also 840 + * makes sure we ignore subsequent zPCI events for this device. 841 + */ 842 + spin_lock(&zpci_list_lock); 843 + list_del(&zdev->entry); 844 + spin_unlock(&zpci_list_lock); 845 + zdev->state = ZPCI_FN_STATE_RESERVED; 846 + zpci_dbg(3, "rsv fid:%x\n", zdev->fid); 847 + zpci_zdev_put(zdev); 848 + } 849 + 833 850 void zpci_release_device(struct kref *kref) 834 851 { 835 852 struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref); ··· 876 843 case ZPCI_FN_STATE_STANDBY: 877 844 if (zdev->has_hp_slot) 878 845 zpci_exit_slot(zdev); 846 + spin_lock(&zpci_list_lock); 847 + list_del(&zdev->entry); 848 + spin_unlock(&zpci_list_lock); 849 + zpci_dbg(3, "rsv fid:%x\n", zdev->fid); 850 + fallthrough; 851 + case ZPCI_FN_STATE_RESERVED: 879 852 if (zdev->has_resources) 880 853 zpci_cleanup_bus_resources(zdev); 881 854 zpci_bus_device_unregister(zdev); ··· 890 851 default: 891 852 break; 892 853 } 893 - 894 - spin_lock(&zpci_list_lock); 895 - list_del(&zdev->entry); 896 - spin_unlock(&zpci_list_lock); 897 854 zpci_dbg(3, "rem fid:%x\n", zdev->fid); 898 855 kfree(zdev); 899 856 }
+2 -2
arch/s390/pci/pci_event.c
··· 140 140 /* The 0x0304 event may immediately reserve the device */ 141 141 if (!clp_get_state(zdev->fid, &state) && 142 142 state == ZPCI_FN_STATE_RESERVED) { 143 - zpci_zdev_put(zdev); 143 + zpci_device_reserved(zdev); 144 144 } 145 145 } 146 146 break; ··· 151 151 case 0x0308: /* Standby -> Reserved */ 152 152 if (!zdev) 153 153 break; 154 - zpci_zdev_put(zdev); 154 + zpci_device_reserved(zdev); 155 155 break; 156 156 default: 157 157 break;
+1 -8
drivers/pci/hotplug/s390_pci_hpc.c
··· 62 62 struct zpci_dev *zdev = container_of(hotplug_slot, struct zpci_dev, 63 63 hotplug_slot); 64 64 65 - switch (zdev->state) { 66 - case ZPCI_FN_STATE_STANDBY: 67 - *value = 0; 68 - break; 69 - default: 70 - *value = 1; 71 - break; 72 - } 65 + *value = zpci_is_device_configured(zdev) ? 1 : 0; 73 66 return 0; 74 67 } 75 68