Skip to content

Commit 4bff980

Browse files
rodrigorcJiri Kosina
authored andcommitted
HID: steam: use hid_device.driver_data instead of hid_set_drvdata()
When creating the low-level hidraw device, the reference to steam_device was stored using hid_set_drvdata(). But this value is not guaranteed to be kept when set before calling probe. If this pointer is reset, it crashes when opening the emulated hidraw device. It looks like hid_set_drvdata() is for users "avobe" this hid_device, while hid_device.driver_data it for users "below" this one. In this case, we are creating a virtual hidraw device, so we must use hid_device.driver_data. Signed-off-by: Rodrigo Rivas Costa <[email protected]> Tested-by: Mariusz Ceier <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 3e84c76 commit 4bff980

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/hid/hid-steam.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ static bool steam_is_valve_interface(struct hid_device *hdev)
573573

574574
static int steam_client_ll_parse(struct hid_device *hdev)
575575
{
576-
struct steam_device *steam = hid_get_drvdata(hdev);
576+
struct steam_device *steam = hdev->driver_data;
577577

578578
return hid_parse_report(hdev, steam->hdev->dev_rdesc,
579579
steam->hdev->dev_rsize);
@@ -590,7 +590,7 @@ static void steam_client_ll_stop(struct hid_device *hdev)
590590

591591
static int steam_client_ll_open(struct hid_device *hdev)
592592
{
593-
struct steam_device *steam = hid_get_drvdata(hdev);
593+
struct steam_device *steam = hdev->driver_data;
594594
int ret;
595595

596596
ret = hid_hw_open(steam->hdev);
@@ -605,7 +605,7 @@ static int steam_client_ll_open(struct hid_device *hdev)
605605

606606
static void steam_client_ll_close(struct hid_device *hdev)
607607
{
608-
struct steam_device *steam = hid_get_drvdata(hdev);
608+
struct steam_device *steam = hdev->driver_data;
609609

610610
mutex_lock(&steam->mutex);
611611
steam->client_opened = false;
@@ -623,7 +623,7 @@ static int steam_client_ll_raw_request(struct hid_device *hdev,
623623
size_t count, unsigned char report_type,
624624
int reqtype)
625625
{
626-
struct steam_device *steam = hid_get_drvdata(hdev);
626+
struct steam_device *steam = hdev->driver_data;
627627

628628
return hid_hw_raw_request(steam->hdev, reportnum, buf, count,
629629
report_type, reqtype);
@@ -710,7 +710,7 @@ static int steam_probe(struct hid_device *hdev,
710710
ret = PTR_ERR(steam->client_hdev);
711711
goto client_hdev_fail;
712712
}
713-
hid_set_drvdata(steam->client_hdev, steam);
713+
steam->client_hdev->driver_data = steam;
714714

715715
/*
716716
* With the real steam controller interface, do not connect hidraw.

0 commit comments

Comments
 (0)