Skip to content

Commit 1ba893a

Browse files
author
Benjamin Tissoires
committed
Merge branch 'for-6.6/devm-fixes' into for-linus
Fix a wrong devm attachment to the input device which now triggers a use after free with a recent devm change by Rahul Rameshbabu.
2 parents 1143823 + 197d314 commit 1ba893a

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

drivers/hid/hid-multitouch.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,7 +1594,6 @@ static void mt_post_parse(struct mt_device *td, struct mt_application *app)
15941594
static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
15951595
{
15961596
struct mt_device *td = hid_get_drvdata(hdev);
1597-
char *name;
15981597
const char *suffix = NULL;
15991598
struct mt_report_data *rdata;
16001599
struct mt_application *mt_application = NULL;
@@ -1645,15 +1644,9 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi)
16451644
break;
16461645
}
16471646

1648-
if (suffix) {
1649-
name = devm_kzalloc(&hi->input->dev,
1650-
strlen(hdev->name) + strlen(suffix) + 2,
1651-
GFP_KERNEL);
1652-
if (name) {
1653-
sprintf(name, "%s %s", hdev->name, suffix);
1654-
hi->input->name = name;
1655-
}
1656-
}
1647+
if (suffix)
1648+
hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
1649+
"%s %s", hdev->name, suffix);
16571650

16581651
return 0;
16591652
}

drivers/hid/hid-nvidia-shield.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ static struct input_dev *shield_allocate_input_dev(struct hid_device *hdev,
164164
idev->id.product = hdev->product;
165165
idev->id.version = hdev->version;
166166
idev->uniq = hdev->uniq;
167-
idev->name = devm_kasprintf(&idev->dev, GFP_KERNEL, "%s %s", hdev->name,
167+
idev->name = devm_kasprintf(&hdev->dev, GFP_KERNEL, "%s %s", hdev->name,
168168
name_suffix);
169169
if (!idev->name)
170170
goto err_name;

drivers/hid/hid-uclogic-core.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,8 @@ static int uclogic_input_configured(struct hid_device *hdev,
8585
{
8686
struct uclogic_drvdata *drvdata = hid_get_drvdata(hdev);
8787
struct uclogic_params *params = &drvdata->params;
88-
char *name;
8988
const char *suffix = NULL;
9089
struct hid_field *field;
91-
size_t len;
9290
size_t i;
9391
const struct uclogic_params_frame *frame;
9492

@@ -146,14 +144,9 @@ static int uclogic_input_configured(struct hid_device *hdev,
146144
}
147145
}
148146

149-
if (suffix) {
150-
len = strlen(hdev->name) + 2 + strlen(suffix);
151-
name = devm_kzalloc(&hi->input->dev, len, GFP_KERNEL);
152-
if (name) {
153-
snprintf(name, len, "%s %s", hdev->name, suffix);
154-
hi->input->name = name;
155-
}
156-
}
147+
if (suffix)
148+
hi->input->name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
149+
"%s %s", hdev->name, suffix);
157150

158151
return 0;
159152
}

0 commit comments

Comments
 (0)