Skip to content

Commit

Permalink
HID: potential dereference of null pointer
Browse files Browse the repository at this point in the history
commit 13251ce upstream.

The return value of devm_kzalloc() needs to be checked.
To avoid hdev->dev->driver_data to be null in case of the failure of
alloc.

Fixes: 14c9c01 ("HID: add vivaldi HID driver")
Cc: stable@vger.kernel.org
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com>
Link: https://lore.kernel.org/r/20211215083605.117638-1-jiasheng@iscas.ac.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
JiangJias authored and gregkh committed Dec 29, 2021
1 parent 3110bc5 commit ef2dce4
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/hid/hid-vivaldi.c
Expand Up @@ -57,6 +57,9 @@ static int vivaldi_probe(struct hid_device *hdev,
int ret;

drvdata = devm_kzalloc(&hdev->dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata)
return -ENOMEM;

hid_set_drvdata(hdev, drvdata);

ret = hid_parse(hdev);
Expand Down

0 comments on commit ef2dce4

Please sign in to comment.