Skip to content

Commit 0726750

Browse files
committed
entity: Use a temp variable in ipmi_entity_find_id
ipmi_entity_find_id() used the same id variable for searching and returning the results. This might result in issues, and it's certainly bad style. Use a temporary variable for searching so the id field only gets modified if the results are found. Reported-by: Alex <aruede@users.noreply.github.com> Signed-off-by: Corey Minyard <corey@minyard.net>
1 parent 30d1bb9 commit 0726750

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

lib/entity.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5592,14 +5592,15 @@ ipmi_entity_find_id(ipmi_domain_id_t domain_id,
55925592
ipmi_entity_id_t *id)
55935593
{
55945594
int rv;
5595+
ipmi_entity_id_t tmp_id;
55955596

5596-
id->domain_id = domain_id;
5597-
id->entity_id = entity_id;
5598-
id->entity_instance = entity_instance;
5599-
id->channel = channel;
5600-
id->address = slave_address;
5597+
tmp_id.domain_id = domain_id;
5598+
tmp_id.entity_id = entity_id;
5599+
tmp_id.entity_instance = entity_instance;
5600+
tmp_id.channel = channel;
5601+
tmp_id.address = slave_address;
56015602

5602-
rv = ipmi_entity_pointer_cb_noseq(*id, get_seq, id);
5603+
rv = ipmi_entity_pointer_cb_noseq(tmp_id, get_seq, id);
56035604
return rv;
56045605
}
56055606

0 commit comments

Comments
 (0)