Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

libceph: simplify ceph_monc_handle_map()

ceph_monc_handle_map() confuses static checkers which report a
false use-after-free on monc->monmap, missing that monc->monmap and
client->monc.monmap is the same pointer.

Use monc->monmap consistently and get rid of "old", which is redundant.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>

+4 -4
+4 -4
net/ceph/mon_client.c
··· 467 467 struct ceph_msg *msg) 468 468 { 469 469 struct ceph_client *client = monc->client; 470 - struct ceph_monmap *monmap = NULL, *old = monc->monmap; 470 + struct ceph_monmap *monmap; 471 471 void *p, *end; 472 472 473 473 mutex_lock(&monc->mutex); ··· 484 484 goto out; 485 485 } 486 486 487 - if (ceph_check_fsid(monc->client, &monmap->fsid) < 0) { 487 + if (ceph_check_fsid(client, &monmap->fsid) < 0) { 488 488 kfree(monmap); 489 489 goto out; 490 490 } 491 491 492 - client->monc.monmap = monmap; 493 - kfree(old); 492 + kfree(monc->monmap); 493 + monc->monmap = monmap; 494 494 495 495 __ceph_monc_got_map(monc, CEPH_SUB_MONMAP, monc->monmap->epoch); 496 496 client->have_fsid = true;