From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Return-Path: Subject: Re: [RFC PATCH 29/30] vfio: Add support for Shared Virtual Memory To: Jean-Philippe Brucker References: <20170227195441.5170-1-jean-philippe.brucker@arm.com> <20170227195441.5170-30-jean-philippe.brucker@arm.com> From: Tomasz Nowicki Message-ID: <6723b835-5325-f120-9b49-16209feb3611@semihalf.com> Date: Wed, 26 Apr 2017 13:01:48 +0200 MIME-Version: 1.0 In-Reply-To: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lorenzo Pieralisi , Shanker Donthineni , kvm@vger.kernel.org, Catalin Marinas , Joerg Roedel , Sinan Kaya , Will Deacon , Alex Williamson , Harv Abdulhamid , iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, Bjorn Helgaas , Robin Murphy , David Woodhouse , linux-arm-kernel@lists.infradead.org, Nate Watterson Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+bjorn=helgaas.com@lists.infradead.org List-ID: On 26.04.2017 12:08, Jean-Philippe Brucker wrote: > On 26/04/17 07:53, Tomasz Nowicki wrote: >>> + mutex_lock(&device->tasks_lock); >>> + list_for_each_entry(vfio_task, &device->tasks, list) { >>> + if (vfio_task->pasid != svm.pasid) >>> + continue; >>> + >>> + ret = iommu_unbind_task(device->dev, svm.pasid, flags); >>> + if (ret) >>> + dev_warn(device->dev, "failed to unbind PASID %u\n", >>> + vfio_task->pasid); >>> + >>> + list_del(&vfio_task->list); >>> + kfree(vfio_task); >> >> Please use list_for_each_entry_safe. > > There is: > > + break; > > right after kfree, so we'd never follow vfio_task->list.next after freeing > vfio_task. The code searches for the _only_ task matching the PASID, > removes it and leaves the loop. > Ah right. Sorry for the noise. Tomasz _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tomasz Nowicki Subject: Re: [RFC PATCH 29/30] vfio: Add support for Shared Virtual Memory Date: Wed, 26 Apr 2017 13:01:48 +0200 Message-ID: <6723b835-5325-f120-9b49-16209feb3611@semihalf.com> References: <20170227195441.5170-1-jean-philippe.brucker@arm.com> <20170227195441.5170-30-jean-philippe.brucker@arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Cc: Lorenzo Pieralisi , Shanker Donthineni , kvm@vger.kernel.org, Catalin Marinas , Joerg Roedel , Sinan Kaya , Will Deacon , iommu@lists.linux-foundation.org, Harv Abdulhamid , Alex Williamson , linux-pci@vger.kernel.org, Bjorn Helgaas , Robin Murphy , David Woodhouse , linux-arm-kernel@lists.infradead.org, Nate Watterson To: Jean-Philippe Brucker Return-path: Received: from mail-lf0-f47.google.com ([209.85.215.47]:32921 "EHLO mail-lf0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2999039AbdDZLBv (ORCPT ); Wed, 26 Apr 2017 07:01:51 -0400 Received: by mail-lf0-f47.google.com with SMTP id 88so105727710lfr.0 for ; Wed, 26 Apr 2017 04:01:50 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 26.04.2017 12:08, Jean-Philippe Brucker wrote: > On 26/04/17 07:53, Tomasz Nowicki wrote: >>> + mutex_lock(&device->tasks_lock); >>> + list_for_each_entry(vfio_task, &device->tasks, list) { >>> + if (vfio_task->pasid != svm.pasid) >>> + continue; >>> + >>> + ret = iommu_unbind_task(device->dev, svm.pasid, flags); >>> + if (ret) >>> + dev_warn(device->dev, "failed to unbind PASID %u\n", >>> + vfio_task->pasid); >>> + >>> + list_del(&vfio_task->list); >>> + kfree(vfio_task); >> >> Please use list_for_each_entry_safe. > > There is: > > + break; > > right after kfree, so we'd never follow vfio_task->list.next after freeing > vfio_task. The code searches for the _only_ task matching the PASID, > removes it and leaves the loop. > Ah right. Sorry for the noise. Tomasz From mboxrd@z Thu Jan 1 00:00:00 1970 From: tn@semihalf.com (Tomasz Nowicki) Date: Wed, 26 Apr 2017 13:01:48 +0200 Subject: [RFC PATCH 29/30] vfio: Add support for Shared Virtual Memory In-Reply-To: References: <20170227195441.5170-1-jean-philippe.brucker@arm.com> <20170227195441.5170-30-jean-philippe.brucker@arm.com> Message-ID: <6723b835-5325-f120-9b49-16209feb3611@semihalf.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On 26.04.2017 12:08, Jean-Philippe Brucker wrote: > On 26/04/17 07:53, Tomasz Nowicki wrote: >>> + mutex_lock(&device->tasks_lock); >>> + list_for_each_entry(vfio_task, &device->tasks, list) { >>> + if (vfio_task->pasid != svm.pasid) >>> + continue; >>> + >>> + ret = iommu_unbind_task(device->dev, svm.pasid, flags); >>> + if (ret) >>> + dev_warn(device->dev, "failed to unbind PASID %u\n", >>> + vfio_task->pasid); >>> + >>> + list_del(&vfio_task->list); >>> + kfree(vfio_task); >> >> Please use list_for_each_entry_safe. > > There is: > > + break; > > right after kfree, so we'd never follow vfio_task->list.next after freeing > vfio_task. The code searches for the _only_ task matching the PASID, > removes it and leaves the loop. > Ah right. Sorry for the noise. Tomasz