diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2014-03-27 20:21:36 +0100 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2014-03-27 20:21:36 +0100 |
commit | 1294c5f96d6279a3f9ac4100b2af63debca8996d (patch) | |
tree | e5b9908efb09ca2736a0a6b5bbf986bedf0b1098 | |
parent | eb927f93563a69c834a09d92ca7c4ffc15027496 (diff) | |
download | external_libsamsung-ipc-1294c5f96d6279a3f9ac4100b2af63debca8996d.zip external_libsamsung-ipc-1294c5f96d6279a3f9ac4100b2af63debca8996d.tar.gz external_libsamsung-ipc-1294c5f96d6279a3f9ac4100b2af63debca8996d.tar.bz2 |
ipc: Carefully check for name or board name when detecting device
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
-rw-r--r-- | samsung-ipc/ipc.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/samsung-ipc/ipc.c b/samsung-ipc/ipc.c index 68e99e0..f019642 100644 --- a/samsung-ipc/ipc.c +++ b/samsung-ipc/ipc.c @@ -45,9 +45,9 @@ int ipc_device_detect(void) { char buffer[4096] = { 0 }; struct utsname utsname; + char *name = NULL; char *board_name = NULL; char *kernel_version = NULL; - char *name = NULL; char *line, *p, *c; int index = -1; int fd = -1; @@ -104,7 +104,14 @@ int ipc_device_detect(void) kernel_version = strdup(utsname.release); #endif + if (name == NULL && board_name == NULL) + goto error; + for (i = 0; i < (int) ipc_devices_count; i++) { + // Eliminate index if neither name nor board name can be checked + if (ipc_devices[i].name == NULL && ipc_devices[i].board_name == NULL) + continue; + // Eliminate index if the name doesn't match if (name != NULL && ipc_devices[i].name != NULL && strcmp(name, ipc_devices[i].name) != 0) continue; @@ -132,6 +139,9 @@ error: index = -1; complete: + if (name != NULL) + free(name); + if (board_name != NULL) free(board_name); |