From patchwork Fri Apr 26 14:52:36 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 2494051 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 2EC353FC64 for ; Fri, 26 Apr 2013 14:52:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755569Ab3DZOwk (ORCPT ); Fri, 26 Apr 2013 10:52:40 -0400 Received: from mail-ie0-f175.google.com ([209.85.223.175]:64011 "EHLO mail-ie0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753642Ab3DZOwj (ORCPT ); Fri, 26 Apr 2013 10:52:39 -0400 Received: by mail-ie0-f175.google.com with SMTP id a11so4948365iee.20 for ; Fri, 26 Apr 2013 07:52:38 -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 :references:in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=3S8NsCNh6PfuU69xjuqFOi3LTUQWSOwWQ61U3S2AF4Q=; b=cIoitp8/p99kbFKiYXAT3ibJZZc6azANAbqMeD9FRpQAw9bs8wHuMZFvEAht6a1Uhk y4mMV3kGPmijciG9O0R0QMqanQnjS2EwbVIpZmJm4yyXBsYugXT1/5Jqn1qa3xcuS7ei NtgGCqIF6in42iujSDMygaRzJSHMK+Qk1tH8Lxz5PgVg+FwVE8ajuJDoVDqEthQdrQGC SVXe0qd+lflrhWyJIhvtq7g/LRrSFUSZSDWnuzSSiivfv49WSOgcBiQtt/SSsRngJ2Lo K+omAQns2nXlK2KH0w9CegEbl/dx8ZuxwAnhLWjjy5/vG+x911AtmrfYeupZdPg/Io4U vbNQ== X-Received: by 10.50.112.6 with SMTP id im6mr2154949igb.17.1366987958491; Fri, 26 Apr 2013 07:52:38 -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 qs4sm3479277igb.10.2013.04.26.07.52.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 26 Apr 2013 07:52:37 -0700 (PDT) Message-ID: <517A94B4.4080804@inktank.com> Date: Fri, 26 Apr 2013 09:52:36 -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 2/4] rbd: fix image id leak in initial probe References: <517A945B.9040304@inktank.com> In-Reply-To: <517A945B.9040304@inktank.com> X-Gm-Message-State: ALoCoQkLhd/OqDAn6fBM+yGCukY7+YR3J5bt6wYIqQhpgfnkVF81wjsNjK+4L0aVZhMOr9imUfiA Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org If a format 2 image id is found for an image being mapped, but the subsequent probe of the image fails, rbd_dev_probe() quits without freeing the image id. Fix that. Also drop a redundant hunk of code in rbd_dev_image_id(). Signed-off-by: Alex Elder Reviewed-by: Josh Durgin --- drivers/block/rbd.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 0774ae1..e79dfe2 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -4794,17 +4794,21 @@ static int rbd_dev_probe(struct rbd_device *rbd_dev) ret = rbd_dev_v2_probe(rbd_dev); else ret = rbd_dev_v1_probe(rbd_dev); - if (ret) { - dout("probe failed, returning %d\n", ret); - - return ret; - } + if (ret) + goto out_err; ret = rbd_dev_probe_finish(rbd_dev); if (ret) rbd_header_free(&rbd_dev->header); return ret; +out_err: + kfree(rbd_dev->spec->image_id); + rbd_dev->spec->image_id = NULL; + + dout("probe failed, returning %d\n", ret); + + return ret; } static ssize_t rbd_add(struct bus_type *bus,