Skip to content

Commit

Permalink
MT#55283 redis: cover a usage of write DB with lock
Browse files Browse the repository at this point in the history
Just cover it with already existing lock
used below, but move upper.

Fixes Covery Scan detected defect:

*** CID 1621443:  Concurrent data access violations  (MISSING_LOCK)
/daemon/redis.c: 2232 in json_restore_call()
2226                            call_destroy(c);
2227                    release_closed_sockets();
2228                    if (must_release_pop) // avoid deadlock with redis_notify->lock below
2229                            redis_ports_release_pop(false);
2230                    must_release_pop = false;
2231
>>>     CID 1621443:  Concurrent data access violations  (MISSING_LOCK)
>>>     Accessing "rtpe_redis_write->db" without holding lock "redis.lock".
>>>     Elsewhere, "redis.db" is written to with "redis.lock" held 1 out of 1 times.
2232                    redis_select_db(rtpe_redis_write, rtpe_redis_write->db);
2233
2234                    mutex_lock(&rtpe_redis_write->lock);
2235                    redisCommandNR(rtpe_redis_write->ctx, "DEL " PB, PBSTR(callid));
2236                    mutex_unlock(&rtpe_redis_write->lock);
2237

Change-Id: Iff3425451f82218480dcc08f42ea7bddbd6f672f
(cherry picked from commit bebc6f8)
  • Loading branch information
zenichev authored and rfuchs committed Jan 27, 2025
1 parent 6df71f2 commit 0a9b5fb
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion daemon/redis.c
Original file line number Diff line number Diff line change
Expand Up @@ -2229,9 +2229,10 @@ static void json_restore_call(struct redis *r, const str *callid, bool foreign)
redis_ports_release_pop(false);
must_release_pop = false;

mutex_lock(&rtpe_redis_write->lock);

redis_select_db(rtpe_redis_write, rtpe_redis_write->db);

mutex_lock(&rtpe_redis_write->lock);
redisCommandNR(rtpe_redis_write->ctx, "DEL " PB, PBSTR(callid));
mutex_unlock(&rtpe_redis_write->lock);

Expand Down

0 comments on commit 0a9b5fb

Please sign in to comment.