Commit 4d8b8fb4 authored by Ilya Dryomov's avatar Ilya Dryomov
Browse files

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: default avatarIlya Dryomov <idryomov@gmail.com>
parent 8ccf7fcc
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -467,7 +467,7 @@ static void ceph_monc_handle_map(struct ceph_mon_client *monc,
				 struct ceph_msg *msg)
{
	struct ceph_client *client = monc->client;
	struct ceph_monmap *monmap = NULL, *old = monc->monmap;
	struct ceph_monmap *monmap;
	void *p, *end;

	mutex_lock(&monc->mutex);
@@ -484,13 +484,13 @@ static void ceph_monc_handle_map(struct ceph_mon_client *monc,
		goto out;
	}

	if (ceph_check_fsid(monc->client, &monmap->fsid) < 0) {
	if (ceph_check_fsid(client, &monmap->fsid) < 0) {
		kfree(monmap);
		goto out;
	}

	client->monc.monmap = monmap;
	kfree(old);
	kfree(monc->monmap);
	monc->monmap = monmap;

	__ceph_monc_got_map(monc, CEPH_SUB_MONMAP, monc->monmap->epoch);
	client->have_fsid = true;