Skip to content

Commit 53ffa6a

Browse files
JiangJiasbentiss
authored andcommitted
HID: amd_sfh: Add missing check for dma_alloc_coherent
Add check for the return value of the dma_alloc_coherent since it may return NULL pointer if allocation fails. Fixes: 4b2c53d ("SFH:Transport Driver to add support of AMD Sensor Fusion Hub (SFH)") Signed-off-by: Jiasheng Jiang <[email protected]> Acked-by: Basavaraj Natikar <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 0ee2981 commit 53ffa6a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/hid/amd-sfh-hid/amd_sfh_client.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
237237
in_data->sensor_virt_addr[i] = dma_alloc_coherent(dev, sizeof(int) * 8,
238238
&cl_data->sensor_dma_addr[i],
239239
GFP_KERNEL);
240+
if (!in_data->sensor_virt_addr[i]) {
241+
rc = -ENOMEM;
242+
goto cleanup;
243+
}
240244
cl_data->sensor_sts[i] = SENSOR_DISABLED;
241245
cl_data->sensor_requested_cnt[i] = 0;
242246
cl_data->cur_hid_dev = i;

0 commit comments

Comments
 (0)