All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Tina Zhang <tina.zhang@intel.com>, iommu@lists.linux.dev
Cc: baolu.lu@linux.intel.com
Subject: Re: [PATCH v2 7/7] iommu/vt-d: Remove BUG_ON in dmar_insert_dev_scope()
Date: Fri, 31 Mar 2023 11:27:38 +0800	[thread overview]
Message-ID: <74239dba-34c7-e565-a293-16e022523f4c@linux.intel.com> (raw)
In-Reply-To: <20230331024236.2716001-8-tina.zhang@intel.com>

On 3/31/23 10:42 AM, Tina Zhang wrote:
> The dmar_insert_dev_scope() could fail if any unexpected condition is
> encountered. However, in this situation, the kernel should attempt
> recovery and proceed with execution. Remove BUG_ON with WARN_ON, so that
> kernel can avoid being crashed when an unexpected condition occurs.
> 
> Signed-off-by: Tina Zhang <tina.zhang@intel.com>
> ---
>   drivers/iommu/intel/dmar.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> index 9684c96247f8..7eceee081235 100644
> --- a/drivers/iommu/intel/dmar.c
> +++ b/drivers/iommu/intel/dmar.c
> @@ -262,7 +262,8 @@ int dmar_insert_dev_scope(struct dmar_pci_notify_info *info,
>   						   get_device(dev));
>   				return 1;
>   			}
> -		BUG_ON(i >= devices_cnt);
> +		if (WARN_ON(i >= devices_cnt))
> +			return -EINVAL;

You have returned an error number. Do you still need a WARN_ON()?

>   	}
>   
>   	return 0;

Best regards,
baolu

  reply	other threads:[~2023-03-31  3:27 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31  2:42 [PATCH v2 0/7] iommu/vt-d: Several fixes for intel iommu driver Tina Zhang
2023-03-31  2:42 ` [PATCH v2 1/7] iommu/vt-d: Fix operand size in bitwise operation Tina Zhang
2023-03-31  2:42 ` [PATCH v2 2/7] iommu/vt-d: Remove BUG_ON on checking valid pfn range Tina Zhang
2023-03-31  2:42 ` [PATCH v2 3/7] iommu/vt-d: Remove BUG_ON in handling iotlb cache invalidation Tina Zhang
2023-03-31  2:42 ` [PATCH v2 4/7] iommu/vt-d: Remove BUG_ON when domain->pgd is NULL Tina Zhang
2023-03-31  3:25   ` Baolu Lu
2023-03-31  4:30     ` tina.zhang
2023-03-31  2:42 ` [PATCH v2 5/7] iommu/vt-d: Remove BUG_ON in map/unmap() Tina Zhang
2023-03-31  2:42 ` [PATCH v2 6/7] iommu/vt-d: Remove a useless BUG_ON(dev->is_virtfn) Tina Zhang
2023-03-31  2:42 ` [PATCH v2 7/7] iommu/vt-d: Remove BUG_ON in dmar_insert_dev_scope() Tina Zhang
2023-03-31  3:27   ` Baolu Lu [this message]
2023-03-31  4:29     ` tina.zhang

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=74239dba-34c7-e565-a293-16e022523f4c@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=tina.zhang@intel.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.