[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID:
<SN6PR02MB41576B119D0FDC7C5D1448D1D4D32@SN6PR02MB4157.namprd02.prod.outlook.com>
Date: Mon, 1 Jul 2024 03:47:14 +0000
From: Michael Kelley <mhklinux@...look.com>
To: Haoxiang Li <make24@...as.ac.cn>, "kys@...rosoft.com" <kys@...rosoft.com>,
"haiyangz@...rosoft.com" <haiyangz@...rosoft.com>, "wei.liu@...nel.org"
<wei.liu@...nel.org>, "decui@...rosoft.com" <decui@...rosoft.com>,
"parri.andrea@...il.com" <parri.andrea@...il.com>, "mikelley@...rosoft.com"
<mikelley@...rosoft.com>
CC: "linux-hyperv@...r.kernel.org" <linux-hyperv@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] Drivers: hv: vmbus: Add missing check for dma_set_mask in
vmbus_device_register()
From: Haoxiang Li <make24@...as.ac.cn> Sent: Sunday, June 30, 2024 7:31 PM
>
> child_device_obj->device cannot perform DMA properly if dma_set_mask()
> returns non-zero. Add check for dma_set_mask() and return the error if it
> fails. child_device_obj->device is not initialized here, so use kfree() to
> free child_device_obj->device.
>
> Fixes: 3a5469582c24 ("Drivers: hv: vmbus: Fix initialization of device object in
> vmbus_device_register()")
> Signed-off-by: Haoxiang Li <make24@...as.ac.cn>
> ---
> drivers/hv/vmbus_drv.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
> index 12a707ab73f8..daa584eaa2af 100644
> --- a/drivers/hv/vmbus_drv.c
> +++ b/drivers/hv/vmbus_drv.c
> @@ -1897,7 +1897,13 @@ 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) {
> + pr_err("64-bit DMA enable failed\n");
> + kfree(&child_device_obj->device);
> + return ret;
> + }
I commented on a previous attempt to check the return value from
dma_set_mask(). See [1]. See also commit f92a4b50f0bd that adds
some detail about the error handling in vmbus_device_register(). It's
all rather messy. I have not personally worked through the details, so
I'm not sure of what the right cleanup is. But I don't think it is
sufficient to just do the kfree() as your patch proposes. Or if I'm wrong,
and that *is* sufficient, please provides details on the reasoning
why, and let's make sure to record that for future reference! :-)
Michael
[1] https://lore.kernel.org/linux-hyperv/20230607014310.19850-1-jiasheng@iscas.ac.cn/
Powered by blists - more mailing lists