HID: uclogic: Add NULL check in uclogic_input_configured()
[ Upstream commit bd07f751208ba190f9b0db5e5b7f35d5bb4a8a1e ]
devm_kasprintf() returns NULL when memory allocation fails. Currently,
uclogic_input_configured() does not check for this case, which results
in a NULL pointer dereference.
Add NULL check after devm_kasprintf() to prevent this issue.
Fixes: dd613a4e45
("HID: uclogic: Correct devm device reference for hidinput input_dev name")
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4715f16b1e
commit
ad6caaf29b
@@ -142,11 +142,12 @@ static int uclogic_input_configured(struct hid_device *hdev,
|
|||||||
suffix = "System Control";
|
suffix = "System Control";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (suffix)
|
|
||||||
hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
|
hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
|
||||||
"%s %s", hdev->name, suffix);
|
"%s %s", hdev->name, suffix);
|
||||||
|
if (!hi->input->name)
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user