aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2016-07-13 12:05:57 -0400
committerJiri Kosina <jkosina@suse.cz>2016-08-05 07:39:14 -0400
commitc1f5409b74c14ac021ef847e034356c904bc7882 (patch)
tree4cad6aa02d379cd112594e8757411c0ea49a487c
parent2df68a8864883ff006b76f50dfc32fd230247ef9 (diff)
HID: wacom: use devm_kasprintf for allocating the name of the remote
The sysfs group was indeed removed by kobject_put(wacom->remote_dir) in wacom_remove(), but the name of the group was never freed. Also remove the misplaced kobject_put(wacom->remote_dir) in the error path of wacom_remote_create_attr_group(). Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Acked-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/wacom_sys.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index c08a7522fdb9..ec088c1a4868 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -25,7 +25,6 @@
25#define WAC_CMD_RETRIES 10 25#define WAC_CMD_RETRIES 10
26#define WAC_CMD_DELETE_PAIRING 0x20 26#define WAC_CMD_DELETE_PAIRING 0x20
27#define WAC_CMD_UNPAIR_ALL 0xFF 27#define WAC_CMD_UNPAIR_ALL 0xFF
28#define WAC_REMOTE_SERIAL_MAX_STRLEN 9
29 28
30#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP) 29#define DEV_ATTR_RW_PERM (S_IRUGO | S_IWUSR | S_IWGRP)
31#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP) 30#define DEV_ATTR_WO_PERM (S_IWUSR | S_IWGRP)
@@ -1233,23 +1232,21 @@ DEVICE_EKR_ATTR_GROUP(4);
1233int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial, int index) 1232int wacom_remote_create_attr_group(struct wacom *wacom, __u32 serial, int index)
1234{ 1233{
1235 int error = 0; 1234 int error = 0;
1236 char *buf;
1237 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1235 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1238 1236
1239 wacom_wac->serial[index] = serial; 1237 wacom_wac->serial[index] = serial;
1240 1238
1241 buf = kzalloc(WAC_REMOTE_SERIAL_MAX_STRLEN, GFP_KERNEL); 1239 wacom->remote_group[index].name = devm_kasprintf(&wacom->hdev->dev,
1242 if (!buf) 1240 GFP_KERNEL,
1241 "%d", serial);
1242 if (!wacom->remote_group[index].name)
1243 return -ENOMEM; 1243 return -ENOMEM;
1244 snprintf(buf, WAC_REMOTE_SERIAL_MAX_STRLEN, "%d", serial);
1245 wacom->remote_group[index].name = buf;
1246 1244
1247 error = sysfs_create_group(wacom->remote_dir, 1245 error = sysfs_create_group(wacom->remote_dir,
1248 &wacom->remote_group[index]); 1246 &wacom->remote_group[index]);
1249 if (error) { 1247 if (error) {
1250 hid_err(wacom->hdev, 1248 hid_err(wacom->hdev,
1251 "cannot create sysfs group err: %d\n", error); 1249 "cannot create sysfs group err: %d\n", error);
1252 kobject_put(wacom->remote_dir);
1253 return error; 1250 return error;
1254 } 1251 }
1255 1252
@@ -1271,7 +1268,8 @@ void wacom_remote_destroy_attr_group(struct wacom *wacom, __u32 serial)
1271 if (wacom->remote_group[i].name) { 1268 if (wacom->remote_group[i].name) {
1272 sysfs_remove_group(wacom->remote_dir, 1269 sysfs_remove_group(wacom->remote_dir,
1273 &wacom->remote_group[i]); 1270 &wacom->remote_group[i]);
1274 kfree(wacom->remote_group[i].name); 1271 devm_kfree(&wacom->hdev->dev,
1272 (char *)wacom->remote_group[i].name);
1275 wacom->remote_group[i].name = NULL; 1273 wacom->remote_group[i].name = NULL;
1276 } 1274 }
1277 } 1275 }