From patchwork Thu Mar 1 06:24:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chengguang Xu X-Patchwork-Id: 10250459 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 32E2F60211 for ; Thu, 1 Mar 2018 06:25:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FF6B28F63 for ; Thu, 1 Mar 2018 06:25:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1444A28F66; Thu, 1 Mar 2018 06:25:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 921F628F63 for ; Thu, 1 Mar 2018 06:25:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966322AbeCAGZf (ORCPT ); Thu, 1 Mar 2018 01:25:35 -0500 Received: from mr11p00im-asmtp002.me.com ([17.110.69.253]:34307 "EHLO mr11p00im-asmtp002.me.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966268AbeCAGZe (ORCPT ); Thu, 1 Mar 2018 01:25:34 -0500 Received: from process-dkim-sign-daemon.mr11p00im-asmtp002.me.com by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) id <0P4W00G00DSD8E00@mr11p00im-asmtp002.me.com> for ceph-devel@vger.kernel.org; Thu, 01 Mar 2018 06:25:10 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=04042017; t=1519885510; bh=bAE5+vFa4XdE9Ms0maD0YHFvw7u5RoaLXV6NhEpJ+qg=; h=From:To:Subject:Date:Message-id; b=hm42ca//rzOAQf0TXdTiwggLddV+s9sGuG4ZpL+CA2Z9cjJecDO1aveioUeb0mT/P CLLgZv2VfhlIlzP0jMnS6Et40k1eSTA5EtgCHkUFls11sTfwXynnnWftCqTTP+VT63 FnNk1yRXWA/hXjGy96928+VRudw++1TSAIMnYeJrn1Uzw7d2UCotSQ1ld9x8+1/XxO aktrH0+ViNCo9bIOqoMv0gSqUf6AjtaGQR3s2thS/H34epuPmaVExMANUOOoSFba6b KAVOfSXEDehkLtjK8gsRLMY/1grU7kp1DZWUotW1T7LB3gobu1lL25LrYdiW44ydiI 8lVO6rt6cVIFQ== Received: from icloud.com ([127.0.0.1]) by mr11p00im-asmtp002.me.com (Oracle Communications Messaging Server 8.0.1.2.20170607 64bit (built Jun 7 2017)) with ESMTPSA id <0P4W00CJFF5HOB30@mr11p00im-asmtp002.me.com>; Thu, 01 Mar 2018 06:25:08 +0000 (GMT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-01_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1803010083 From: Chengguang Xu To: ceph-devel@vger.kernel.org Cc: zyan@redhat.com, idryomov@gmail.com, sage@redhat.com, Chengguang Xu Subject: [PATCH] ceph: fix potential memory leak Date: Thu, 01 Mar 2018 14:24:51 +0800 Message-id: <1519885491-163018-1-git-send-email-cgxu519@icloud.com> X-Mailer: git-send-email 1.8.3.1 Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There is lack of cache destroy operation for ceph_file_cachep when failing from fscache register. Signed-off-by: Chengguang Xu --- fs/ceph/super.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/ceph/super.c b/fs/ceph/super.c index a62d2a9..564bddc 100644 --- a/fs/ceph/super.c +++ b/fs/ceph/super.c @@ -711,14 +711,17 @@ static int __init init_caches(void) goto bad_dentry; ceph_file_cachep = KMEM_CACHE(ceph_file_info, SLAB_MEM_SPREAD); - if (!ceph_file_cachep) goto bad_file; - if ((error = ceph_fscache_register())) - goto bad_file; + error = ceph_fscache_register(); + if (error) + goto bad_fscache; return 0; + +bad_fscache: + kmem_cache_destroy(ceph_file_cachep); bad_file: kmem_cache_destroy(ceph_dentry_cachep); bad_dentry: