lkml.org 
[lkml]   [2022]   [Dec]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] vfio/ap/ccw/samples: Fix device_register() unwind path
From


On 12/2/22 11:46 AM, Alex Williamson wrote:
> We always need to call put_device() if device_register() fails.
> All vfio drivers calling device_register() include a similar unwind
> stack via gotos, therefore split device_unregister() into its
> device_del() and put_device() components in the unwind path, and
> add a goto target to handle only the put_device() requirement.
>
> Reported-by: Ruan Jinjie <ruanjinjie@huawei.com>
> Link: https://lore.kernel.org/all/20221118032827.3725190-1-ruanjinjie@huawei.com
> Fixes: d61fc96f47fd ("sample: vfio mdev display - host device")
> Fixes: 9d1a546c53b4 ("docs: Sample driver to demonstrate how to use Mediated device framework.")
> Fixes: a5e6e6505f38 ("sample: vfio bochs vbe display (host device for bochs-drm)")
> Fixes: 9e6f07cd1eaa ("vfio/ccw: create a parent struct")
> Fixes: 36360658eb5a ("s390: vfio_ap: link the vfio_ap devices to the vfio_ap bus subsystem")
> Cc: Tony Krowiak <akrowiak@linux.ibm.com>
> Cc: Halil Pasic <pasic@linux.ibm.com>
> Cc: Jason Herne <jjherne@linux.ibm.com>
> Cc: Kirti Wankhede <kwankhede@nvidia.com>
> Reviewed-by: Kevin Tian <kevin.tian@intel.com>
> Reviewed-by: Eric Farman <farman@linux.ibm.com>
> Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
> ---
>
> I didn't intend to usurp Ruan's patch, but since the inline version is
> collecting reviews, formally post it and include additional fixes tags
> for vfio-ccw and vfio-ap.
>
> drivers/s390/cio/vfio_ccw_drv.c | 3 ++-
> drivers/s390/crypto/vfio_ap_drv.c | 2 +-
> samples/vfio-mdev/mbochs.c | 7 ++++---
> samples/vfio-mdev/mdpy.c | 7 ++++---
> samples/vfio-mdev/mtty.c | 7 ++++---
> 5 files changed, 15 insertions(+), 11 deletions(-)
>
> ...
> diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c
> index f43cfeabd2cc..997b524bdd2b 100644
> --- a/drivers/s390/crypto/vfio_ap_drv.c
> +++ b/drivers/s390/crypto/vfio_ap_drv.c
> @@ -122,7 +122,7 @@ static int vfio_ap_matrix_dev_create(void)
> return 0;
>
> matrix_drv_err:
> - device_unregister(&matrix_dev->device);
> + device_del(&matrix_dev->device);
> matrix_reg_err:
> put_device(&matrix_dev->device);
> matrix_alloc_err:

Reviewed-by: Jason J. Herne <jjherne@linux.ibm.com>


\
 
 \ /
  Last update: 2022-12-05 14:41    [W:0.084 / U:1.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site