Message ID | 20220802112447.249436-3-eperezma@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | vdpa: Merge all net_init_vhost_vdpa error goto | expand |
On 02/08/2022 13:24, Eugenio Pérez wrote: > Few steps allocate new resources, and all of the allocated can be > checked to avoid trying to free an invalid one. > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> > --- > net/vhost-vdpa.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > index 303447a68e..ac1810723c 100644 > --- a/net/vhost-vdpa.c > +++ b/net/vhost-vdpa.c > @@ -588,8 +588,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features, > &has_cvq, errp); > if (queue_pairs < 0) { > - qemu_close(vdpa_device_fd); > - return queue_pairs; > + goto err; > } > > if (opts->x_svq) { > @@ -604,7 +603,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > if (invalid_dev_features) { > error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64, > invalid_dev_features); > - goto err_svq; > + goto err; > } > > vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); > @@ -640,7 +639,6 @@ err: > } > } > > -err_svq: > qemu_close(vdpa_device_fd); > > return -1; Reviewed-by: Laurent Vivier <lvivier@redhat.com>
On Tue, Aug 02, 2022 at 02:10:43PM +0200, Laurent Vivier wrote: > On 02/08/2022 13:24, Eugenio Pérez wrote: > > Few steps allocate new resources, and all of the allocated can be > > checked to avoid trying to free an invalid one. > > > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> qemu-trivial too I guess then? Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > > --- > > net/vhost-vdpa.c | 6 ++---- > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > > index 303447a68e..ac1810723c 100644 > > --- a/net/vhost-vdpa.c > > +++ b/net/vhost-vdpa.c > > @@ -588,8 +588,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > > queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features, > > &has_cvq, errp); > > if (queue_pairs < 0) { > > - qemu_close(vdpa_device_fd); > > - return queue_pairs; > > + goto err; > > } > > if (opts->x_svq) { > > @@ -604,7 +603,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > > if (invalid_dev_features) { > > error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64, > > invalid_dev_features); > > - goto err_svq; > > + goto err; > > } > > vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); > > @@ -640,7 +639,6 @@ err: > > } > > } > > -err_svq: > > qemu_close(vdpa_device_fd); > > return -1; > > Reviewed-by: Laurent Vivier <lvivier@redhat.com>
On 02/08/2022 14:57, Michael S. Tsirkin wrote: > On Tue, Aug 02, 2022 at 02:10:43PM +0200, Laurent Vivier wrote: >> On 02/08/2022 13:24, Eugenio Pérez wrote: >>> Few steps allocate new resources, and all of the allocated can be >>> checked to avoid trying to free an invalid one. >>> >>> Signed-off-by: Eugenio Pérez <eperezma@redhat.com> > > > qemu-trivial too I guess then? For 7.1 or later? Thanks, Laurent > > Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > >>> --- >>> net/vhost-vdpa.c | 6 ++---- >>> 1 file changed, 2 insertions(+), 4 deletions(-) >>> >>> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c >>> index 303447a68e..ac1810723c 100644 >>> --- a/net/vhost-vdpa.c >>> +++ b/net/vhost-vdpa.c >>> @@ -588,8 +588,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, >>> queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features, >>> &has_cvq, errp); >>> if (queue_pairs < 0) { >>> - qemu_close(vdpa_device_fd); >>> - return queue_pairs; >>> + goto err; >>> } >>> if (opts->x_svq) { >>> @@ -604,7 +603,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, >>> if (invalid_dev_features) { >>> error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64, >>> invalid_dev_features); >>> - goto err_svq; >>> + goto err; >>> } >>> vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); >>> @@ -640,7 +639,6 @@ err: >>> } >>> } >>> -err_svq: >>> qemu_close(vdpa_device_fd); >>> return -1; >> >> Reviewed-by: Laurent Vivier <lvivier@redhat.com> >
On Tue, Aug 02, 2022 at 02:58:36PM +0200, Laurent Vivier wrote: > On 02/08/2022 14:57, Michael S. Tsirkin wrote: > > On Tue, Aug 02, 2022 at 02:10:43PM +0200, Laurent Vivier wrote: > > > On 02/08/2022 13:24, Eugenio Pérez wrote: > > > > Few steps allocate new resources, and all of the allocated can be > > > > checked to avoid trying to free an invalid one. > > > > > > > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> > > > > > > qemu-trivial too I guess then? > > For 7.1 or later? > > Thanks, > Laurent I don't really care. Since you are merging this you get to decide. > > > > Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > > > > > > --- > > > > net/vhost-vdpa.c | 6 ++---- > > > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > > > > index 303447a68e..ac1810723c 100644 > > > > --- a/net/vhost-vdpa.c > > > > +++ b/net/vhost-vdpa.c > > > > @@ -588,8 +588,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > > > > queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features, > > > > &has_cvq, errp); > > > > if (queue_pairs < 0) { > > > > - qemu_close(vdpa_device_fd); > > > > - return queue_pairs; > > > > + goto err; > > > > } > > > > if (opts->x_svq) { > > > > @@ -604,7 +603,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > > > > if (invalid_dev_features) { > > > > error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64, > > > > invalid_dev_features); > > > > - goto err_svq; > > > > + goto err; > > > > } > > > > vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); > > > > @@ -640,7 +639,6 @@ err: > > > > } > > > > } > > > > -err_svq: > > > > qemu_close(vdpa_device_fd); > > > > return -1; > > > > > > Reviewed-by: Laurent Vivier <lvivier@redhat.com> > >
On Tue, Aug 2, 2022 at 3:10 PM Michael S. Tsirkin <mst@redhat.com> wrote: > > On Tue, Aug 02, 2022 at 02:58:36PM +0200, Laurent Vivier wrote: > > On 02/08/2022 14:57, Michael S. Tsirkin wrote: > > > On Tue, Aug 02, 2022 at 02:10:43PM +0200, Laurent Vivier wrote: > > > > On 02/08/2022 13:24, Eugenio Pérez wrote: > > > > > Few steps allocate new resources, and all of the allocated can be > > > > > checked to avoid trying to free an invalid one. > > > > > > > > > > Signed-off-by: Eugenio Pérez <eperezma@redhat.com> > > > > > > > > > qemu-trivial too I guess then? > > > > For 7.1 or later? > > > > Thanks, > > Laurent > > I don't really care. Since you are merging this you get to decide. > In my opinion it's better to leave that for a later revision. I sent it to trivial because it only touches a few lines of code and it's easy to review even without knowledge of net or vdpa subsystem, but if it's not appropriate I can send future patches like this out of trivial. Thanks! > > > > > > Reviewed-by: Michael S. Tsirkin <mst@redhat.com> > > > > > > > > --- > > > > > net/vhost-vdpa.c | 6 ++---- > > > > > 1 file changed, 2 insertions(+), 4 deletions(-) > > > > > > > > > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > > > > > index 303447a68e..ac1810723c 100644 > > > > > --- a/net/vhost-vdpa.c > > > > > +++ b/net/vhost-vdpa.c > > > > > @@ -588,8 +588,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > > > > > queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features, > > > > > &has_cvq, errp); > > > > > if (queue_pairs < 0) { > > > > > - qemu_close(vdpa_device_fd); > > > > > - return queue_pairs; > > > > > + goto err; > > > > > } > > > > > if (opts->x_svq) { > > > > > @@ -604,7 +603,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, > > > > > if (invalid_dev_features) { > > > > > error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64, > > > > > invalid_dev_features); > > > > > - goto err_svq; > > > > > + goto err; > > > > > } > > > > > vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); > > > > > @@ -640,7 +639,6 @@ err: > > > > > } > > > > > } > > > > > -err_svq: > > > > > qemu_close(vdpa_device_fd); > > > > > return -1; > > > > > > > > Reviewed-by: Laurent Vivier <lvivier@redhat.com> > > > >
diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c index 303447a68e..ac1810723c 100644 --- a/net/vhost-vdpa.c +++ b/net/vhost-vdpa.c @@ -588,8 +588,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, queue_pairs = vhost_vdpa_get_max_queue_pairs(vdpa_device_fd, features, &has_cvq, errp); if (queue_pairs < 0) { - qemu_close(vdpa_device_fd); - return queue_pairs; + goto err; } if (opts->x_svq) { @@ -604,7 +603,7 @@ int net_init_vhost_vdpa(const Netdev *netdev, const char *name, if (invalid_dev_features) { error_setg(errp, "vdpa svq does not work with features 0x%" PRIx64, invalid_dev_features); - goto err_svq; + goto err; } vhost_vdpa_get_iova_range(vdpa_device_fd, &iova_range); @@ -640,7 +639,6 @@ err: } } -err_svq: qemu_close(vdpa_device_fd); return -1;
Few steps allocate new resources, and all of the allocated can be checked to avoid trying to free an invalid one. Signed-off-by: Eugenio Pérez <eperezma@redhat.com> --- net/vhost-vdpa.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)