linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Logan Gunthorpe <logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org,
	linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: "Jens Axboe" <axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org>,
	"Christian König" <christian.koenig-5C7GfCeVMHo@public.gmane.org>,
	"Benjamin Herrenschmidt"
	<benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>,
	"Alex Williamson"
	<alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"Jérôme Glisse" <jglisse-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	"Jason Gunthorpe" <jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	"Bjorn Helgaas"
	<bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	"Max Gurtovoy" <maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>,
	"Christoph Hellwig" <hch-jcswGhMUV9g@public.gmane.org>
Subject: Re: [PATCH v7 02/13] PCI/P2PDMA: Add sysfs group to display p2pmem stats
Date: Tue, 25 Sep 2018 11:31:20 -0700	[thread overview]
Message-ID: <1537900280.11137.30.camel@acm.org> (raw)
In-Reply-To: <9241a6af-9826-d1ff-c13b-882cb3b6a34a-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>

On Tue, 2018-09-25 at 12:15 -0600, Logan Gunthorpe wrote:
> On 2018-09-25 11:29 a.m., Bart Van Assche wrote:
> > On Tue, 2018-09-25 at 10:22 -0600, Logan Gunthorpe wrote:
> > > @@ -83,9 +132,14 @@ static int pci_p2pdma_setup(struct pci_dev *pdev)
> > >  
> > >  	pdev->p2pdma = p2p;
> > >  
> > > +	error = sysfs_create_group(&pdev->dev.kobj, &p2pmem_group);
> > > +	if (error)
> > > +		goto out_pool_destroy;
> > > +
> > >  	return 0;
> > >  
> > >  out_pool_destroy:
> > > +	pdev->p2pdma = NULL;
> > >  	gen_pool_destroy(p2p->pool);
> > >  out:
> > >  	devm_kfree(&pdev->dev, p2p);
> > 
> > This doesn't look right to me. Shouldn't devm_remove_action() be called instead
> > of devm_kfree() if sysfs_create_group() fails?
> 
> That makes no sense to me. We are reversing a devm_kzalloc() not a
> custom action....

In case what I wrote was not clear: both devm_kzalloc() and
devm_add_action_or_reset() have to be reversed if sysfs_create_group() fails.
devm_add_action_or_reset() calls devres_add(). The latter function adds an
element to the dev->devres_head list. So I think that only calling devm_kfree()
if sysfs_create_group() fails will lead to corruption of the dev->devres_head
list.

Bart.

  parent reply	other threads:[~2018-09-25 18:31 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-25 16:22 [PATCH v7 00/13] Copy Offload in NVMe Fabrics with P2P PCI Memory Logan Gunthorpe
2018-09-25 16:22 ` [PATCH v7 06/13] PCI/P2PDMA: Add P2P DMA driver writer's documentation Logan Gunthorpe
     [not found] ` <20180925162231.4354-1-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-09-25 16:22   ` [PATCH v7 01/13] PCI/P2PDMA: Support peer-to-peer memory Logan Gunthorpe
     [not found]     ` <20180925162231.4354-2-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-09-25 17:25       ` Bart Van Assche
     [not found]         ` <1537896340.11137.19.camel-HInyCGIudOg@public.gmane.org>
2018-09-25 18:09           ` Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 02/13] PCI/P2PDMA: Add sysfs group to display p2pmem stats Logan Gunthorpe
     [not found]     ` <20180925162231.4354-3-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-09-25 17:29       ` Bart Van Assche
     [not found]         ` <1537896555.11137.22.camel-HInyCGIudOg@public.gmane.org>
2018-09-25 18:15           ` Logan Gunthorpe
     [not found]             ` <9241a6af-9826-d1ff-c13b-882cb3b6a34a-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-09-25 18:31               ` Bart Van Assche [this message]
2018-09-25 18:51                 ` Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 03/13] PCI/P2PDMA: Add PCI p2pmem DMA mappings to adjust the bus offset Logan Gunthorpe
     [not found]     ` <20180925162231.4354-4-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-09-25 17:33       ` Bart Van Assche
     [not found]         ` <1537896805.11137.25.camel-HInyCGIudOg@public.gmane.org>
2018-09-25 18:46           ` Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 04/13] PCI/P2PDMA: Introduce configfs/sysfs enable attribute helpers Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 05/13] docs-rst: Add a new directory for PCI documentation Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 07/13] block: Add PCI P2P flag for request queue and check support for requests Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 08/13] IB/core: Ensure we map P2P memory correctly in rdma_rw_ctx_[init|destroy]() Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 09/13] nvme-pci: Use PCI p2pmem subsystem to manage the CMB Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 10/13] nvme-pci: Add support for P2P memory in requests Logan Gunthorpe
     [not found]     ` <20180925162231.4354-11-logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-09-25 17:11       ` Keith Busch
     [not found]         ` <20180925171147.GB11822-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2018-09-25 17:41           ` Logan Gunthorpe
     [not found]             ` <3549a9bb-3604-1739-c008-4e1a95441333-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org>
2018-09-25 17:48               ` Keith Busch
2018-09-25 16:22   ` [PATCH v7 11/13] nvme-pci: Add a quirk for a pseudo CMB Logan Gunthorpe
2018-09-25 16:22   ` [PATCH v7 12/13] nvmet: Introduce helper functions to allocate and free request SGLs Logan Gunthorpe
2018-09-25 16:22 ` [PATCH v7 13/13] nvmet: Optionally use PCI P2P memory Logan Gunthorpe

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=1537900280.11137.30.camel@acm.org \
    --to=bvanassche-hinycgiudog@public.gmane.org \
    --cc=alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=axboe-tSWWG44O7X1aa/9Udqfwiw@public.gmane.org \
    --cc=benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org \
    --cc=bhelgaas-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    --cc=christian.koenig-5C7GfCeVMHo@public.gmane.org \
    --cc=hch-jcswGhMUV9g@public.gmane.org \
    --cc=jgg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    --cc=jglisse-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=linux-block-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-nvdimm-hn68Rpc1hR1g9hUCZPvPmw@public.gmane.org \
    --cc=linux-nvme-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=linux-pci-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=logang-OTvnGxWRz7hWk0Htik3J/w@public.gmane.org \
    --cc=maxg-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).