diff --git a/fs/ceph/osdmap.c b/fs/ceph/osdmap.c
index 50ce64ebd3301eb24cf358ca7d6c1cdb6c0fe444..277f8b33957757ef506f6ac18816699b6b8156da 100644
--- a/fs/ceph/osdmap.c
+++ b/fs/ceph/osdmap.c
@@ -568,6 +568,7 @@ struct ceph_osdmap *osdmap_decode(void **p, void *end)
 		if (ev > CEPH_PG_POOL_VERSION) {
 			pr_warning("got unknown v %d > %d of ceph_pg_pool\n",
 				   ev, CEPH_PG_POOL_VERSION);
+			kfree(pi);
 			goto bad;
 		}
 		__decode_pool(p, pi);