From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752859AbbIOQTN (ORCPT ); Tue, 15 Sep 2015 12:19:13 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:18796 "EHLO aserp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751729AbbIOQTL (ORCPT ); Tue, 15 Sep 2015 12:19:11 -0400 Date: Tue, 15 Sep 2015 09:18:55 -0700 From: "Darrick J. Wong" To: device-mapper development Cc: Alasdair Kergon , Mike Snitzer , Neil Brown , linux-raid@vger.kernel.org, linux-kernel@vger.kernel.org, Sudip Mukherjee Subject: Re: [dm-devel] [PATCH] dm: ioctl: prevent double freeing Message-ID: <20150915161855.GE10399@birch.djwong.org> References: <1441365759-7247-1-git-send-email-sudipm.mukherjee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1441365759-7247-1-git-send-email-sudipm.mukherjee@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: userv0021.oracle.com [156.151.31.71] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 04, 2015 at 04:52:39PM +0530, Sudip Mukherjee wrote: > DM_PARAMS_KMALLOC and DM_PARAMS_VMALLOC should never be set together in > param_flags. We are setting these flags while allocating so we know that > there is almost no chance of having these two set together but still we > can have some additional safety. > > Signed-off-by: Sudip Mukherjee > --- > drivers/md/dm-ioctl.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c > index 80a4395..aaad74e 100644 > --- a/drivers/md/dm-ioctl.c > +++ b/drivers/md/dm-ioctl.c > @@ -1680,7 +1680,7 @@ static void free_params(struct dm_ioctl *param, size_t param_size, int param_fla > > if (param_flags & DM_PARAMS_KMALLOC) > kfree(param); > - if (param_flags & DM_PARAMS_VMALLOC) > + else if (param_flags & DM_PARAMS_VMALLOC) Wouldn't you also want a WARN_ON to complain about both flags being set? --D > vfree(param); > } > > -- > 1.9.1 > > -- > dm-devel mailing list > dm-devel@redhat.com > https://www.redhat.com/mailman/listinfo/dm-devel