From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9B9ACC352AA for ; Wed, 2 Oct 2019 09:22:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7C58721783 for ; Wed, 2 Oct 2019 09:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbfJBJWH (ORCPT ); Wed, 2 Oct 2019 05:22:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:57440 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725848AbfJBJWH (ORCPT ); Wed, 2 Oct 2019 05:22:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 9A5ECAE8A; Wed, 2 Oct 2019 09:22:05 +0000 (UTC) Received: by ds.suse.cz (Postfix, from userid 10065) id 5D024DA88C; Wed, 2 Oct 2019 11:22:21 +0200 (CEST) Date: Wed, 2 Oct 2019 11:22:21 +0200 From: David Sterba To: Navid Emamdoost Cc: Markus.Elfring@web.de, "Gustavo A. R. Silva" , Deepa Dinamani , Jeff Layton , Thomas Gleixner , Greg Kroah-Hartman , David Sterba , emamd001@umn.edu, kjlu@umn.edu, smccaman@umn.edu, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro Subject: Re: [PATCH v2] fs: affs: fix a memory leak in affs_remount Message-ID: <20191002092221.GJ2751@suse.cz> Reply-To: dsterba@suse.cz Mail-Followup-To: dsterba@suse.cz, Navid Emamdoost , Markus.Elfring@web.de, "Gustavo A. R. Silva" , Deepa Dinamani , Jeff Layton , Thomas Gleixner , Greg Kroah-Hartman , David Sterba , emamd001@umn.edu, kjlu@umn.edu, smccaman@umn.edu, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro References: <20190930210114.6557-1-navid.emamdoost@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190930210114.6557-1-navid.emamdoost@gmail.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Mon, Sep 30, 2019 at 04:01:10PM -0500, Navid Emamdoost wrote: > In affs_remount if data is provided it is duplicated into new_opts. > The allocated memory for new_opts is only released if pare_options fail. > The release for new_opts is added. A variable that is allocated and freed without use should ring a bell to look closer at the code. There's a bit of history behind new_options, originally there was save/replace options on the VFS layer so the 'data' passed must not change (thus strdup), this got cleaned up in later patches. But not completely. There's no reason to do the strdup in cases where the filesystem does not need to reuse the 'data' again, because strsep would modify it directly. So new_opts should be removed.