Bug 219955 - Missing null check in winwing_init_led
Summary: Missing null check in winwing_init_led
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Input Devices (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: drivers_input-devices
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-28 12:48 UTC by henry
Modified: 2025-03-28 12:48 UTC (History)
0 users

See Also:
Kernel Version:
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description henry 2025-03-28 12:48:46 UTC
hid: hid-winwing.c
Add NULL check in the winwing_init_led

When devm_kasprintf() fails, it returns a NULL pointer. However, this return value is not properly checked in the function winwing_init_led. 

A NULL check should be added after the devm_kasprintf call to handle potential NULL pointer dereference error.

CODE:
		led->cdev.brightness_set_blocking = winwing_led_write;
		led->cdev.flags = LED_HW_PLUGGABLE;
		led->cdev.name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
						"%s::%s",
						dev_name(&input->dev),
						info->led_name);

		ret = devm_led_classdev_register(&hdev->dev, &led->cdev);
		if (ret)
			return ret;

Note You need to log in before you can comment on or make changes to this bug.