Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost

Pull virtio fixes from Michael Tsirkin:
"Several small bugfixes all over the place"

* tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost:
vdpa/mlx5: Fix error path during device add
vp_vdpa: fix id_table array not null terminated error
virtio_pci: Fix admin vq cleanup by using correct info pointer
vDPA/ifcvf: Fix pci_read_config_byte() return code handling
Fix typo in vringh_test.c
vdpa: solidrun: Fix UB bug with devres
vsock/virtio: Initialization of the dangling pointer occurring in vsk->trans

+45 -42
+1 -1
drivers/vdpa/ifcvf/ifcvf_base.c
··· 108 108 u32 i; 109 109 110 110 ret = pci_read_config_byte(pdev, PCI_CAPABILITY_LIST, &pos); 111 - if (ret < 0) { 111 + if (ret) { 112 112 IFCVF_ERR(pdev, "Failed to read PCI capability list\n"); 113 113 return -EIO; 114 114 }
+5 -16
drivers/vdpa/mlx5/net/mlx5_vnet.c
··· 3963 3963 mvdev->vdev.dma_dev = &mdev->pdev->dev; 3964 3964 err = mlx5_vdpa_alloc_resources(&ndev->mvdev); 3965 3965 if (err) 3966 - goto err_mpfs; 3966 + goto err_alloc; 3967 3967 3968 3968 err = mlx5_vdpa_init_mr_resources(mvdev); 3969 3969 if (err) 3970 - goto err_res; 3970 + goto err_alloc; 3971 3971 3972 3972 if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) { 3973 3973 err = mlx5_vdpa_create_dma_mr(mvdev); 3974 3974 if (err) 3975 - goto err_mr_res; 3975 + goto err_alloc; 3976 3976 } 3977 3977 3978 3978 err = alloc_fixed_resources(ndev); 3979 3979 if (err) 3980 - goto err_mr; 3980 + goto err_alloc; 3981 3981 3982 3982 ndev->cvq_ent.mvdev = mvdev; 3983 3983 INIT_WORK(&ndev->cvq_ent.work, mlx5_cvq_kick_handler); 3984 3984 mvdev->wq = create_singlethread_workqueue("mlx5_vdpa_wq"); 3985 3985 if (!mvdev->wq) { 3986 3986 err = -ENOMEM; 3987 - goto err_res2; 3987 + goto err_alloc; 3988 3988 } 3989 3989 3990 3990 mvdev->vdev.mdev = &mgtdev->mgtdev; ··· 4010 4010 _vdpa_unregister_device(&mvdev->vdev); 4011 4011 err_reg: 4012 4012 destroy_workqueue(mvdev->wq); 4013 - err_res2: 4014 - free_fixed_resources(ndev); 4015 - err_mr: 4016 - mlx5_vdpa_clean_mrs(mvdev); 4017 - err_mr_res: 4018 - mlx5_vdpa_destroy_mr_resources(mvdev); 4019 - err_res: 4020 - mlx5_vdpa_free_resources(&ndev->mvdev); 4021 - err_mpfs: 4022 - if (!is_zero_ether_addr(config->mac)) 4023 - mlx5_mpfs_del_mac(pfmdev, config->mac); 4024 4013 err_alloc: 4025 4014 put_device(&mvdev->vdev.dev); 4026 4015 return err;
+10 -4
drivers/vdpa/solidrun/snet_main.c
··· 555 555 556 556 static int psnet_open_pf_bar(struct pci_dev *pdev, struct psnet *psnet) 557 557 { 558 - char name[50]; 558 + char *name; 559 559 int ret, i, mask = 0; 560 560 /* We don't know which BAR will be used to communicate.. 561 561 * We will map every bar with len > 0. ··· 573 573 return -ENODEV; 574 574 } 575 575 576 - snprintf(name, sizeof(name), "psnet[%s]-bars", pci_name(pdev)); 576 + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "psnet[%s]-bars", pci_name(pdev)); 577 + if (!name) 578 + return -ENOMEM; 579 + 577 580 ret = pcim_iomap_regions(pdev, mask, name); 578 581 if (ret) { 579 582 SNET_ERR(pdev, "Failed to request and map PCI BARs\n"); ··· 593 590 594 591 static int snet_open_vf_bar(struct pci_dev *pdev, struct snet *snet) 595 592 { 596 - char name[50]; 593 + char *name; 597 594 int ret; 598 595 599 - snprintf(name, sizeof(name), "snet[%s]-bar", pci_name(pdev)); 596 + name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "snet[%s]-bars", pci_name(pdev)); 597 + if (!name) 598 + return -ENOMEM; 599 + 600 600 /* Request and map BAR */ 601 601 ret = pcim_iomap_regions(pdev, BIT(snet->psnet->cfg.vf_bar), name); 602 602 if (ret) {
+7 -3
drivers/vdpa/virtio_pci/vp_vdpa.c
··· 612 612 goto mdev_err; 613 613 } 614 614 615 - mdev_id = kzalloc(sizeof(struct virtio_device_id), GFP_KERNEL); 615 + /* 616 + * id_table should be a null terminated array, so allocate one additional 617 + * entry here, see vdpa_mgmtdev_get_classes(). 618 + */ 619 + mdev_id = kcalloc(2, sizeof(struct virtio_device_id), GFP_KERNEL); 616 620 if (!mdev_id) { 617 621 err = -ENOMEM; 618 622 goto mdev_id_err; ··· 636 632 goto probe_err; 637 633 } 638 634 639 - mdev_id->device = mdev->id.device; 640 - mdev_id->vendor = mdev->id.vendor; 635 + mdev_id[0].device = mdev->id.device; 636 + mdev_id[0].vendor = mdev->id.vendor; 641 637 mgtdev->id_table = mdev_id; 642 638 mgtdev->max_supported_vqs = vp_modern_get_num_queues(mdev); 643 639 mgtdev->supported_features = vp_modern_get_features(mdev);
+18 -6
drivers/virtio/virtio_pci_common.c
··· 24 24 "Force legacy mode for transitional virtio 1 devices"); 25 25 #endif 26 26 27 + bool vp_is_avq(struct virtio_device *vdev, unsigned int index) 28 + { 29 + struct virtio_pci_device *vp_dev = to_vp_device(vdev); 30 + 31 + if (!virtio_has_feature(vdev, VIRTIO_F_ADMIN_VQ)) 32 + return false; 33 + 34 + return index == vp_dev->admin_vq.vq_index; 35 + } 36 + 27 37 /* wait for pending irq handlers */ 28 38 void vp_synchronize_vectors(struct virtio_device *vdev) 29 39 { ··· 244 234 return vq; 245 235 } 246 236 247 - static void vp_del_vq(struct virtqueue *vq) 237 + static void vp_del_vq(struct virtqueue *vq, struct virtio_pci_vq_info *info) 248 238 { 249 239 struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); 250 - struct virtio_pci_vq_info *info = vp_dev->vqs[vq->index]; 251 240 unsigned long flags; 252 241 253 242 /* ··· 267 258 void vp_del_vqs(struct virtio_device *vdev) 268 259 { 269 260 struct virtio_pci_device *vp_dev = to_vp_device(vdev); 261 + struct virtio_pci_vq_info *info; 270 262 struct virtqueue *vq, *n; 271 263 int i; 272 264 273 265 list_for_each_entry_safe(vq, n, &vdev->vqs, list) { 274 - if (vp_dev->per_vq_vectors) { 275 - int v = vp_dev->vqs[vq->index]->msix_vector; 266 + info = vp_is_avq(vdev, vq->index) ? vp_dev->admin_vq.info : 267 + vp_dev->vqs[vq->index]; 276 268 269 + if (vp_dev->per_vq_vectors) { 270 + int v = info->msix_vector; 277 271 if (v != VIRTIO_MSI_NO_VECTOR && 278 272 !vp_is_slow_path_vector(v)) { 279 273 int irq = pci_irq_vector(vp_dev->pci_dev, v); ··· 285 273 free_irq(irq, vq); 286 274 } 287 275 } 288 - vp_del_vq(vq); 276 + vp_del_vq(vq, info); 289 277 } 290 278 vp_dev->per_vq_vectors = false; 291 279 ··· 366 354 vring_interrupt, 0, 367 355 vp_dev->msix_names[msix_vec], vq); 368 356 if (err) { 369 - vp_del_vq(vq); 357 + vp_del_vq(vq, *p_info); 370 358 return ERR_PTR(err); 371 359 } 372 360
+1
drivers/virtio/virtio_pci_common.h
··· 178 178 #define VIRTIO_ADMIN_CMD_BITMAP 0 179 179 #endif 180 180 181 + bool vp_is_avq(struct virtio_device *vdev, unsigned int index); 181 182 void vp_modern_avq_done(struct virtqueue *vq); 182 183 int vp_modern_admin_cmd_exec(struct virtio_device *vdev, 183 184 struct virtio_admin_cmd *cmd);
+1 -11
drivers/virtio/virtio_pci_modern.c
··· 43 43 return 0; 44 44 } 45 45 46 - static bool vp_is_avq(struct virtio_device *vdev, unsigned int index) 47 - { 48 - struct virtio_pci_device *vp_dev = to_vp_device(vdev); 49 - 50 - if (!virtio_has_feature(vdev, VIRTIO_F_ADMIN_VQ)) 51 - return false; 52 - 53 - return index == vp_dev->admin_vq.vq_index; 54 - } 55 - 56 46 void vp_modern_avq_done(struct virtqueue *vq) 57 47 { 58 48 struct virtio_pci_device *vp_dev = to_vp_device(vq->vdev); ··· 235 245 if (!virtio_has_feature(vdev, VIRTIO_F_ADMIN_VQ)) 236 246 return; 237 247 238 - vq = vp_dev->vqs[vp_dev->admin_vq.vq_index]->vq; 248 + vq = vp_dev->admin_vq.info->vq; 239 249 if (!vq) 240 250 return; 241 251
+1
net/vmw_vsock/virtio_transport_common.c
··· 1109 1109 struct virtio_vsock_sock *vvs = vsk->trans; 1110 1110 1111 1111 kfree(vvs); 1112 + vsk->trans = NULL; 1112 1113 } 1113 1114 EXPORT_SYMBOL_GPL(virtio_transport_destruct); 1114 1115
+1 -1
tools/virtio/vringh_test.c
··· 519 519 errx(1, "virtqueue_add_sgs: %i", err); 520 520 __kmalloc_fake = NULL; 521 521 522 - /* Host retreives it. */ 522 + /* Host retrieves it. */ 523 523 vringh_iov_init(&riov, host_riov, ARRAY_SIZE(host_riov)); 524 524 vringh_iov_init(&wiov, host_wiov, ARRAY_SIZE(host_wiov)); 525 525