From patchwork Tue Jul 22 18:11:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: HIMANGI SARAOGI X-Patchwork-Id: 4604401 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 76C63C0514 for ; Tue, 22 Jul 2014 18:11:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9ED3D20158 for ; Tue, 22 Jul 2014 18:11:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B83B52015E for ; Tue, 22 Jul 2014 18:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751482AbaGVSLl (ORCPT ); Tue, 22 Jul 2014 14:11:41 -0400 Received: from mail-pa0-f51.google.com ([209.85.220.51]:42761 "EHLO mail-pa0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865AbaGVSLk (ORCPT ); Tue, 22 Jul 2014 14:11:40 -0400 Received: by mail-pa0-f51.google.com with SMTP id ey11so21670pad.38 for ; Tue, 22 Jul 2014 11:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mime-version:content-type :content-disposition:user-agent; bh=G/iZPUpZ3tKbtbmQGD8Jd3P6dPtjd3HtxWcw0KSdXA0=; b=Cl6ORe4wfeeNvjkcdnYYxdqgmj+NN8TOtWZCUwiPNlrGSgIC84Qjj2KUB84kJtP8bc 7nQuCxMIUsoE1hPmZIjlcCrGqKjuYe9pX3M33tPuWpv/motDKqut6uM0OuHnS1e31LoJ bCMJtK/dTIaDWnwZfC1+FFx0OC/8prGf9GNdLsTNLRHVy27C+nrCXZ7jH/m3sAOb1322 fF5h3tXf//U8Pqpq2uSuoz2Xqv29uUYf99gmSgWcYIDrBOGxqzX8IHtzp0xYkM7DVqla eqzflfWqmzOCAX7beLZJx+eQe/IPJDd2KofAVg0v6WKlFDi/kEEomze8XV74krq7gUzJ g8+Q== X-Received: by 10.66.219.42 with SMTP id pl10mr36394873pac.22.1406052698950; Tue, 22 Jul 2014 11:11:38 -0700 (PDT) Received: from localhost ([122.164.52.8]) by mx.google.com with ESMTPSA id mz8sm1405106pdb.62.2014.07.22.11.11.34 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 22 Jul 2014 11:11:38 -0700 (PDT) Date: Tue, 22 Jul 2014 23:41:30 +0530 From: Himangi Saraogi To: Yehuda Sadeh , Sage Weil , Alex Elder , ceph-devel@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Julia Lawall Subject: [PATCH] rbd: Use kmem_cache_free Message-ID: <20140722181130.GA3278@himangi-Dell> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Free memory allocated using kmem_cache_zalloc using kmem_cache_free rather than kfree. The Coccinelle semantic patch that makes this change is as follows: // @@ expression x,E,c; @@ x = \(kmem_cache_alloc\|kmem_cache_zalloc\|kmem_cache_alloc_node\)(c,...) ... when != x = E when != &x ?-kfree(x) +kmem_cache_free(c,x) // Signed-off-by: Himangi Saraogi Acked-by: Julia Lawall --- drivers/block/rbd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b2c98c1..8381c54 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -1158,7 +1158,7 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset) if (ret < 0 || ret > CEPH_MAX_OID_NAME_LEN) { pr_err("error formatting segment name for #%llu (%d)\n", segment, ret); - kfree(name); + kmem_cache_free(rbd_segment_name_cache, name); name = NULL; }