Bug 219949 - Missing null check in com20020pci_probe
Summary: Missing null check in com20020pci_probe
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Network (show other bugs)
Hardware: All Linux
: P3 normal
Assignee: drivers_network@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-03-28 10:49 UTC by henry
Modified: 2025-03-28 10:49 UTC (History)
0 users

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


Attachments

Description henry 2025-03-28 10:49:14 UTC
net: arcnet: com20020-pci.c: 
Add null check in the com20020pci_probe

When devm_kasprintf fails, it returns a null pointer. However, this return value is not properly checked in the function com20020pci_probe. 

A null check should be added after the devm_kasprintf call to prevent potential null pointer dereference error. This is similar to the commit 050b23d081da.

CODE:
	card->tx_led.brightness_set = led_tx_set;
	card->tx_led.default_trigger = devm_kasprintf(&pdev->dev,
					GFP_KERNEL, "arc%d-%d-tx",
					dev->dev_id, i);
	card->tx_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
					"pci:green:tx:%d-%d",
					dev->dev_id, i);

	card->tx_led.dev = &dev->dev;
	card->recon_led.brightness_set = led_recon_set;
	card->recon_led.default_trigger = devm_kasprintf(&pdev->dev,
					GFP_KERNEL, "arc%d-%d-recon",
					dev->dev_id, i);
	card->recon_led.name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
					"pci:red:recon:%d-%d",
					dev->dev_id, i);

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