Received: by 10.223.176.5 with SMTP id f5csp2952107wra; Thu, 1 Feb 2018 08:31:12 -0800 (PST) X-Google-Smtp-Source: AH8x227mVKAnyCrmqljQ9WnW4TspAGFA4YWAfdef8O6A+3lfToZRfiSi3aJjdcy5XtgpgnXXDxLq X-Received: by 2002:a17:902:20cb:: with SMTP id v11-v6mr32435949plg.63.1517502672603; Thu, 01 Feb 2018 08:31:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517502672; cv=none; d=google.com; s=arc-20160816; b=SLXgCzHzPLau0x7JdHIIfhBowK56mHnbmEiZXdDTieO0R6GWm3zsvvE2e8GoydMS6F z/Dzj/3a8zKNwjEorwwrNK1pWF0cGu3t7yXXfLEZs06TeVmtpnRy9EHU14ALqEQ7C8U/ PXk0g6uLPDPgBDbY7/rdlTf1kH5YrYTcNArHjbghGHwr4Ap3k5Tu4flZvDMK4EnCSUV5 s6Xkm/M204/LYWrw86elzG/NaE4Sb+R2hj2ebdv1qyFMpOHBNbNLZg/jLCl6sNL1gUHp 7ybkUJGQj9C3Kjju7aFBXcSkMhZwuYsHVj9Sc/Kq8jw+MFe7mJ4DGmT+3qs9P19BBccH bhxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:subject:message-id:date:from :mime-version:dkim-signature:arc-authentication-results; bh=gO8lZsIwMgbB2DlqLgfUblZCUl8LSOPIIXdM1Xkqa2M=; b=fBm7MIZ7kx7mPULn3SbXjIWeApilGqPUzoIcpuWmho/oxyx0Zh+tQ4FeS5XpEItvCr krm4EILG2aEgDvDGUjexlWTMSgA4022hpTfcuM5y6z4v8Mig0jPgitFfJ55n2fdt0Wv2 zJdWMp4ROJF5kXjwXTxGNeMtKP1JlxU48Plag29T5EDi3ke+GtpNoZLwWgWrj0/UaXU8 +0pyiv3q/ZqubmqeYDxQhMWN6yAsCBkZFyYsYB1psViJubdFXpSBoznmMZHX43T5EKrv 7M8ffZyl7jxFRHV74awj6azKGy+VS0HbJFCqo76EuTeCOSh6YnGNoh1nH7A0liiCv64X 2Zhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gO1koyuP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v4-v6si1866817plo.347.2018.02.01.08.30.56; Thu, 01 Feb 2018 08:31:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=gO1koyuP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752166AbeBAQaF (ORCPT + 99 others); Thu, 1 Feb 2018 11:30:05 -0500 Received: from mail-vk0-f52.google.com ([209.85.213.52]:39461 "EHLO mail-vk0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751508AbeBAQaD (ORCPT ); Thu, 1 Feb 2018 11:30:03 -0500 Received: by mail-vk0-f52.google.com with SMTP id a63so11655449vkg.6 for ; Thu, 01 Feb 2018 08:30:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:from:date:message-id:subject:to; bh=gO8lZsIwMgbB2DlqLgfUblZCUl8LSOPIIXdM1Xkqa2M=; b=gO1koyuP40/lJ35Gr5lNNTrgqku6OtY0r9T45BE9S9RC4eIIVOGqVQrg9sTbr4Uo4w FjXThbmIfdtgA6weczx39O7zovvtEZ5O9DjniNvpSWfB7Gs4vYRUGhwN2lypIIIYaty9 ZdGcE0DEj1x94Bam4y8OmarYrnocoupXSTPhCggI7xoM1UMtM+R49kEXsVfXayeKv+OG +2NupGCXYkGrAjAe0QHwf1Ra6XaJ4k8JJ5CZe3U143HGC/FogKH+wD2CDG9q3T0bVa8F taLD/mDIRVtSt6eH4JWtS+bss4Q8CgL2K1xaDm2kac5l3qFujiItkst4KZjowSL2RnmJ 6cWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:from:date:message-id:subject :to; bh=gO8lZsIwMgbB2DlqLgfUblZCUl8LSOPIIXdM1Xkqa2M=; b=NIPH7rhJxTi8XoFIU/DBPl0AnnPirO1nk6v9YMtPR96MiiBo49Vu7cKH682B8LrVMH nESwC5ImKbHUa3dpuvwsTK075Kd3mXkjIwcLDckVPqkq2q/AvC4bTQiTQTPHcA8iH4Tu HrI8/rc8xsrEZiz9SLuz1CIHbO9TKY1Nh7Kosi3bTH9Gq7aBqDLrtvP6T0uvAbmP1gi0 vYbUjxEoZp4RaPSdK2Db1Wbp8P+HkA+xITCG05mgq6myQI8RYb7S3WRAdCRFn9Lwhz0N a+lAEdsgdI7tCEZor2zg5K4Lf8GI+W0E3bAMfsFBbWJe2jlkwfTTvUYYAwehYvmbGj6V Js2g== X-Gm-Message-State: AKwxytcbOu+PQiQeBDEjuo9OoGPXtbWQe1fTv7uiQ7lozhL+AZOv4hua P4dtAgbJxMcST3vf7nz7AOW8GqxK7bmwNGIdsXU= X-Received: by 10.31.48.18 with SMTP id w18mr28478344vkw.62.1517502602723; Thu, 01 Feb 2018 08:30:02 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.78.22 with HTTP; Thu, 1 Feb 2018 08:29:42 -0800 (PST) From: Mathieu Malaterre Date: Thu, 1 Feb 2018 17:29:42 +0100 X-Google-Sender-Auth: 6yjJ4dpHnQPDHsT_7ltRl4tIFQg Message-ID: Subject: cocci script for detecting alloc_apertures mem leak To: Julia Lawall , Gilles Muller , Nicolas Palix , Michal Marek , cocci@systeme.lip6.fr, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi cocci gurus, I am wondering if coccinelle can handle detection of kzalloc mem leak (within alloc_apertures call) ? Typically: $ cat drivers/video/fbdev/vesafb.c static int vesafb_probe(struct platform_device *dev) [...] info->apertures = alloc_apertures(1); but then: static void vesafb_destroy(struct fb_info *info) { struct vesafb_par *par = info->par; fb_dealloc_cmap(&info->cmap); arch_phys_wc_del(par->wc_cookie); if (info->screen_base) iounmap(info->screen_base); release_mem_region(info->apertures->ranges[0].base, info->apertures->ranges[0].size); } For reference: $ cat include/linux/fb.h static inline struct apertures_struct *alloc_apertures(unsigned int max_num) { struct apertures_struct *a = kzalloc(sizeof(struct apertures_struct) + max_num * sizeof(struct aperture), GFP_KERNEL); Thanks for comments,