policy: kdbus_policy_set() use another variable to save entries
authorDjalal Harouni <tixxdz@opendz.org>
Fri, 20 Jun 2014 16:50:03 +0000 (17:50 +0100)
committerDaniel Mack <zonque@gmail.com>
Fri, 20 Jun 2014 17:44:10 +0000 (19:44 +0200)
commit2ab96dd598f55893d3a4576ad771367e525ae2e6
treefc8cffcd86e6af618c74662351fe2f363834185e
parentc0aebb5762e5f2b118408d93156d3d44189b3643
policy: kdbus_policy_set() use another variable to save entries

In kdbus_policy_set() function, we use the 'e' variable to reference
each entry of the 'db->entries_hash', so at the end the variable 'e' will
for sure point to a valid one.

Next in the KDBUS_ITEMS_FOREACH() iterator and if we fail at the first
KDBUS_ITEM_VALID() test, we jmp to exit:

Which contains the following:
if (e)
kdbus_policy_entry_free(e);

Here 'e' points to a valid entry and it will be freed, so even we
restore all the other entries from that list, there will be always one
missing, the last one pointed by that 'e' variable.

To fix this, just use another 'tmp_entry' variable to reference hash
entries.

Signed-off-by: Djalal Harouni <tixxdz@opendz.org>
policy.c