From patchwork Tue May 7 01:33:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2529751 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id C614DDF230 for ; Tue, 7 May 2013 01:33:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759356Ab3EGBdq (ORCPT ); Mon, 6 May 2013 21:33:46 -0400 Received: from mail-ie0-f169.google.com ([209.85.223.169]:60536 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757670Ab3EGBdq (ORCPT ); Mon, 6 May 2013 21:33:46 -0400 Received: by mail-ie0-f169.google.com with SMTP id u16so52788iet.14 for ; Mon, 06 May 2013 18:33:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=+YwtbU1nN1bJunUS/AATaOudwcF3t3AyFD7wxZdQDg4=; b=jR+TzZ9r7On5QLbYAYXhUB8A0JX+oqULpHTrYtoJ3kVIiU+eEUuBFkWL1A6vqca6m9 uSvk6Zdqsx/KAOgvDMp59t3ASUP7qj5D7VvUiXXTno06oRcJK2j+/k2uzSHHPPtWVxEJ 8Ge+hPExBVnhyiaufu5jvIIYMomW5nwwQ9hnKsAR/YFOmwXgZujOyYetfHW3lUTT9LEJ M6UO/Yj2v3JnACawsXmoIKbAzQs5WCpPsvFKj9gX7porFfb4poy1C97ohpJqa4aecnCo 6fPqdfGmt9g65Nc/SFfU1q5kRyFpHDnPa2Uhd1A7h0eg3+4xZSWz6DEDsORTSn2FQdXF BGkQ== X-Received: by 10.42.58.201 with SMTP id j9mr7972572ich.20.1367890425529; Mon, 06 May 2013 18:33:45 -0700 (PDT) Received: from [172.22.22.4] (c-71-195-31-37.hsd1.mn.comcast.net. [71.195.31.37]) by mx.google.com with ESMTPSA id lr1sm6628226igb.6.2013.05.06.18.33.44 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 May 2013 18:33:44 -0700 (PDT) Message-ID: <518859F7.8060708@inktank.com> Date: Mon, 06 May 2013 20:33:43 -0500 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130329 Thunderbird/17.0.5 MIME-Version: 1.0 To: ceph-devel@vger.kernel.org Subject: [PATCH] rbd: fix leak of format 2 snapshot context X-Gm-Message-State: ALoCoQlL0jqhJ0OmNd5XBmR8ArilstZloOpH/G130NpGhpvBWI7VKWSh1g2qu8wO1ru6aOuT9B57 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org When rbd_dev_v2_refresh() is called, the rbd device already has a snapshot context associated with it. But that never gets freed, the pointer just gets overwritten. Fix this by dropping the rbd device's reference to the snapshot context before overwriting the pointer. Because ceph_put_snap_context() already handles for a null pointer we don't need to check for that (for the probe case, where no context has yet been assigned). This resolves: http://tracker.ceph.com/issues/4912 Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 1 + 1 file changed, 1 insertion(+) dout(" snap context seq = %llu, snap_count = %u\n", diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index c2ca181..4263743 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4004,6 +4004,7 @@ static int rbd_dev_v2_snap_context(struct rbd_device *rbd_dev) for (i = 0; i < snap_count; i++) snapc->snaps[i] = ceph_decode_64(&p); + ceph_put_snap_context(rbd_dev->header.snapc); rbd_dev->header.snapc = snapc;