From: Haoxiang Li <make24@iscas.ac.cn>
To: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, parri.andrea@gmail.com,
mikelley@microsoft.com
Cc: linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org,
Haoxiang Li <make24@iscas.ac.cn>
Subject: [PATCH] Drivers: hv: vmbus: Add missing check for dma_set_mask in vmbus_device_register()
Date: Mon, 1 Jul 2024 10:30:59 +0800 [thread overview]
Message-ID: <20240701023059.83616-1-make24@iscas.ac.cn> (raw)
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@iscas.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;
+ }
/*
* Register with the LDM. This will kick off the driver/device
--
2.25.1
next reply other threads:[~2024-07-01 2:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 2:30 Haoxiang Li [this message]
2024-07-01 3:47 ` Michael Kelley
2024-07-01 9:30 ` Markus Elfring
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240701023059.83616-1-make24@iscas.ac.cn \
--to=make24@iscas.ac.cn \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikelley@microsoft.com \
--cc=parri.andrea@gmail.com \
--cc=wei.liu@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®