If hotplug_add_device fails, priv leaks memory Signed-off-by: Peter Hutterer <peter.hutte...@who-t.net> --- stddev.c | 8 ++++++-- wacom.c | 9 +++++++-- 2 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/stddev.c b/stddev.c index 411c2cb..8c971f7 100644 --- a/stddev.c +++ b/stddev.c @@ -192,8 +192,10 @@ int keyboard_add_device(struct session *session, char *path, int type) priv->type = type; rc = hotplug_add_file(session, path); - if (rc) + if (rc) { + free(priv); return rc; + } return monitored_device_add(session->devices, keyboard_init, priv, path); } @@ -256,8 +258,10 @@ int mouse_add_device(struct session *session, char *path, int type) priv->type = type; rc = hotplug_add_file(session, path); - if (rc) + if (rc) { + free(priv); return rc; + } return monitored_device_add(session->devices, mouse_init, priv, path); } diff --git a/wacom.c b/wacom.c index 89f1da6..67f75d4 100644 --- a/wacom.c +++ b/wacom.c @@ -51,16 +51,21 @@ int add_wacom_device(struct session *session, char *path, int type) if (wacom_check_type(type)) { log(LOG_ERR, "Invalid wacom type: %i, use -w to get a " "list\n", type); - return EINVAL; + rc = EINVAL; + goto error; } priv->type = type; rc = hotplug_add_file(session, path); if (rc) - return rc; + goto error; return monitored_device_add(session->devices, wacom_init, priv, path); + +error: + free(priv); + return rc; } #define set_event(x, y, z) do { if (ioctl((x)->fd, (y), (z)) == -1) { \ -- 1.7.11.2 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel