All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: lyl2019@mail.ustc.edu.cn
To: "Fabio Aiuto" <fabioaiuto83@gmail.com>
Cc: rspringer@google.com, toddpoynor@google.com,
	benchan@chromium.org, rcy@google.com, gregkh@linuxfoundation.org,
	linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: Re: [PATCH] Staging:gasket:core: Fix a double free in gasket_enable_device
Date: Tue, 27 Apr 2021 23:02:24 +0800 (GMT+08:00)	[thread overview]
Message-ID: <36b65d1b.64610.17913da4e10.Coremail.lyl2019@mail.ustc.edu.cn> (raw)
In-Reply-To: <20210427142559.GD1399@agape.jhs>




> -----原始邮件-----
> 发件人: "Fabio Aiuto" <fabioaiuto83@gmail.com>
> 发送时间: 2021-04-27 22:26:00 (星期二)
> 收件人: "Lv Yunlong" <lyl2019@mail.ustc.edu.cn>
> 抄送: rspringer@google.com, toddpoynor@google.com, benchan@chromium.org, rcy@google.com, gregkh@linuxfoundation.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org
> 主题: Re: [PATCH] Staging:gasket:core: Fix a double free in gasket_enable_device
> 
> Hi Lv,
> 
> I fear gasket is no more on staging tree, I think it's no more on
> kernel. Try fetch again from remote.
> 
> On Tue, Apr 27, 2021 at 07:11:29AM -0700, Lv Yunlong wrote:
> > In gasket_enable_device, it calls gasket_interrupt_init().
> > Inside gasket_interrupt_init, interrupt_data is allocated via
> > kzalloc() and then is assigned to gasket_dev->interrupt_data.
> > If the later two kzalloc() failed, interrupt_data will be freed
> > and gasket_dev->interrupt_data will point to a freed memory.
> > 
> > After gasket_enable_device received the error, the freed
> > gasket_dev->interrupt_data is freed again in
> > gasket_interrupt_cleanup(gasket_dev).
> > 
> > My patch moves the "gasket_dev->interrupt_data = interrupt_data"
> > assignment behind the later kzalloc() all successd, to avoid
> > gasket_dev->interrupt_data pointing to a freed memory
> > 
> > Fixes: 80666096eb78f ("staging: gasket: core: remove static function forward declarations")
> > Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
> > ---
> >  drivers/staging/gasket/gasket_interrupt.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c
> > index 864342acfd86..d4993d7abb87 100644
> > --- a/drivers/staging/gasket/gasket_interrupt.c
> > +++ b/drivers/staging/gasket/gasket_interrupt.c
> > @@ -322,7 +322,6 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
> >  	interrupt_data = kzalloc(sizeof(*interrupt_data), GFP_KERNEL);
> >  	if (!interrupt_data)
> >  		return -ENOMEM;
> > -	gasket_dev->interrupt_data = interrupt_data;
> >  	interrupt_data->name = driver_desc->name;
> >  	interrupt_data->type = driver_desc->interrupt_type;
> >  	interrupt_data->pci_dev = gasket_dev->pci_dev;
> > @@ -349,6 +348,8 @@ int gasket_interrupt_init(struct gasket_dev *gasket_dev)
> >  		return -ENOMEM;
> >  	}
> >  
> > +	gasket_dev->interrupt_data = interrupt_data;
> > +
> >  	switch (interrupt_data->type) {
> >  	case PCI_MSIX:
> >  		ret = gasket_interrupt_msix_init(interrupt_data);
> > -- 
> > 2.25.1
> > 
> > 
> > 
> 
> thank you,
> 
> fabio


Thanks for your reminder.

      reply	other threads:[~2021-04-27 15:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-27 14:11 [PATCH] Staging:gasket:core: Fix a double free in gasket_enable_device Lv Yunlong
2021-04-27 14:26 ` Fabio Aiuto
2021-04-27 15:02   ` lyl2019 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=36b65d1b.64610.17913da4e10.Coremail.lyl2019@mail.ustc.edu.cn \
    --to=lyl2019@mail.ustc.edu.cn \
    --cc=benchan@chromium.org \
    --cc=fabioaiuto83@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=rcy@google.com \
    --cc=rspringer@google.com \
    --cc=toddpoynor@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.