All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] HID: amd_sfh: Add check for dma_alloc_coherent()
@ 2022-11-25 10:25 Zeng Heng
  0 siblings, 0 replies; only message in thread
From: Zeng Heng @ 2022-11-25 10:25 UTC (permalink / raw)
  To: basavaraj.natikar, Nehal-bakulchandra.Shah, benjamin.tissoires,
	sandeep.singh, jikos
  Cc: liwei391, linux-input, zengheng4

Since the dma_alloc_coherent() may return NULL,
the pointer returned needs to be checked to avoid
null-poineter dereference.

Fixes: 4b2c53d93a4b ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)")
Signed-off-by: Zeng Heng <zengheng4@huawei.com>
---
 drivers/hid/amd-sfh-hid/amd_sfh_client.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/hid/amd-sfh-hid/amd_sfh_client.c b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
index 8275bba63611..ab125f79408f 100644
--- a/drivers/hid/amd-sfh-hid/amd_sfh_client.c
+++ b/drivers/hid/amd-sfh-hid/amd_sfh_client.c
@@ -237,6 +237,10 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
 		in_data->sensor_virt_addr[i] = dma_alloc_coherent(dev, sizeof(int) * 8,
 								  &cl_data->sensor_dma_addr[i],
 								  GFP_KERNEL);
+		if (!in_data->sensor_virt_addr[i]) {
+			rc = -ENOMEM;
+			goto cleanup;
+		}
 		cl_data->sensor_sts[i] = SENSOR_DISABLED;
 		cl_data->sensor_requested_cnt[i] = 0;
 		cl_data->cur_hid_dev = i;
-- 
2.25.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-11-25 10:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-25 10:25 [PATCH] HID: amd_sfh: Add check for dma_alloc_coherent() Zeng Heng

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.