From: Jiasheng Jiang <jiasheng@xxxxxxxxxxx> Sent: Tuesday, June 6, 2023 6:43 PM > > Add check for dma_set_mask() and return the error if it fails. > > Fixes: 6bf625a4140f ("Drivers: hv: vmbus: Rework use of DMA_BIT_MASK(64)") > Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx> > --- > drivers/hv/vmbus_drv.c | 6 +++++- > 1 file changed, 5 insertions(+), 1 deletion(-) > > diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c > index 1c65a6dfb9fa..68b7be2762ea 100644 > --- a/drivers/hv/vmbus_drv.c > +++ b/drivers/hv/vmbus_drv.c > @@ -1908,7 +1908,11 @@ int vmbus_device_register(struct hv_device > *child_device_obj) > > child_device_obj->device.dma_parms = &child_device_obj->dma_parms; > child_device_obj->device.dma_mask = &child_device_obj->dma_mask; > - dma_set_mask(&child_device_obj->device, DMA_BIT_MASK(64)); > + ret = dma_set_mask(&child_device_obj->device, DMA_BIT_MASK(64)); > + if (ret) { > + put_device(&child_device_obj->device); I don't think the put_device() call is correct here. The underlying kobj in child_device_obj->device is not initialized until device_register() calls device_initialize(). It's after device_initialize() is called that put_device() must be used. That said, I don't see that the memory for the child_device_obj gets freed if we just do "return ret", though maybe I'm missing it. And there's the matter of the memory allocated by dev_set_name(). Getting this error path fully correct may be rather awkward. :-( Michael > + return ret; > + } > > /* > * Register with the LDM. This will kick off the driver/device > -- > 2.25.1