From patchwork Mon Aug 6 18:03:38 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 1280631 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 C24E1DF288 for ; Mon, 6 Aug 2012 18:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756844Ab2HFSDk (ORCPT ); Mon, 6 Aug 2012 14:03:40 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:39424 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753685Ab2HFSDk (ORCPT ); Mon, 6 Aug 2012 14:03:40 -0400 Received: by mail-pb0-f46.google.com with SMTP id rr13so2904653pbb.19 for ; Mon, 06 Aug 2012 11:03:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=z2hVQT1vWktkNJQuBy7xa0hV5zek0aCTIyJQOAgumt0=; b=LSQhdNtx4Llby73ib/nXlUEg7PB6Bhh4mFDy9ft5G5zucKZ7RUo86dS2EcL1wtH1Ye dAUrBFklvN9k5KmMpvoaevLQNvFs7iFIe4kMaZU4Otn6L4JnvMa09bBa6mal1+eUu4nZ blZtfz+W8ZeMCZDd8h8Wy+FixHITSwk0LiIKJUMDu6ojF9J0tgN4/X+SbH56r1wX5N6X 2CzWNLbmzT55I+HMrAg4NNvZwmd3y8UX8IqqM806np3ws5FVuUB+i5WuWJmSw2lnUB0o tr2PYj2qW0sRm5ZXETCZdD7AcfZB6p3a+KlXJ4sYLqJoxrZ+d07UvbqNKRbr28ovQ+SC BGpA== Received: by 10.68.231.132 with SMTP id tg4mr21193057pbc.159.1344276220124; Mon, 06 Aug 2012 11:03:40 -0700 (PDT) Received: from ?IPv6:2607:f298:a:607:3c9c:52cb:843e:71a9? ([2607:f298:a:607:3c9c:52cb:843e:71a9]) by mx.google.com with ESMTPS id qc5sm9384817pbb.6.2012.08.06.11.03.39 (version=SSLv3 cipher=OTHER); Mon, 06 Aug 2012 11:03:39 -0700 (PDT) Message-ID: <502006FA.3000801@inktank.com> Date: Mon, 06 Aug 2012 11:03:38 -0700 From: Alex Elder User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120714 Thunderbird/14.0 MIME-Version: 1.0 To: "ceph-devel@vger.kernel.org" Subject: [PATCH 2/3] rbd: ensure invalid pointers are made null References: <50200691.3040006@inktank.com> In-Reply-To: <50200691.3040006@inktank.com> X-Gm-Message-State: ALoCoQn+cC0yVLPIfFlvmKi/sPICr6z8MMmlRNIO2TGpUzzQJw2YGuWxspT+pzKPBgwfFo8ksPc0 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org Fix a number of spots where a pointer value that is known to have become invalid but was not reset to null. Also, toss in a change so we use sizeof (object) rather than sizeof (type). Signed-off-by: Alex Elder --- drivers/block/rbd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe ceph-devel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Index: b/drivers/block/rbd.c =================================================================== --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -569,6 +569,7 @@ err_sizes: err_names: kfree(header->snap_names); header->snap_names = NULL; + header->snap_names_len = 0; err_snapc: kfree(header->snapc); header->snapc = NULL; @@ -632,9 +633,14 @@ done: static void rbd_header_free(struct rbd_image_header *header) { kfree(header->object_prefix); + header->object_prefix = NULL; kfree(header->snap_sizes); + header->snap_sizes = NULL; kfree(header->snap_names); + header->snap_names = NULL; + header->snap_names_len = 0; ceph_put_snap_context(header->snapc); + header->snapc = NULL; } /* @@ -2444,7 +2450,10 @@ static int rbd_add_parse_args(struct rbd out_err: kfree(rbd_dev->header_name); + rbd_dev->header_name = NULL; kfree(rbd_dev->image_name); + rbd_dev->image_name = NULL; + rbd_dev->image_name_len = 0; kfree(rbd_dev->pool_name); rbd_dev->pool_name = NULL; @@ -2496,6 +2505,7 @@ static ssize_t rbd_add(struct bus_type * options); if (IS_ERR(rbd_dev->rbd_client)) { rc = PTR_ERR(rbd_dev->rbd_client); + rbd_dev->rbd_client = NULL; goto err_put_id; }