lkml.org 
[lkml]   [2023]   [May]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    SubjectRe: [PATCH 2/2] iommu/vt-d: Use BUG_ON to check NULL value of 'table'
    From
    On 5/30/23 5:25 PM, Yanfei Xu wrote:
    > Checking NULL value of 'table' variable deserves a BUG_ON as the
    > following code will trigger a crash by dereferencing the NULL
    > 'table' pointer. Crash in advance with BUG_ON to avoid WARN_ON
    > plus NULL pointer dereferencing can simplify the crash log.
    >
    > Signed-off-by: Yanfei Xu<yanfei.xu@intel.com>
    > ---
    > drivers/iommu/intel/iommu.c | 2 +-
    > 1 file changed, 1 insertion(+), 1 deletion(-)
    >
    > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
    > index e98f1b122b49..8aa3bfdb7f95 100644
    > --- a/drivers/iommu/intel/iommu.c
    > +++ b/drivers/iommu/intel/iommu.c
    > @@ -1944,7 +1944,7 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
    > if (sm_supported(iommu)) {
    > unsigned long pds;
    >
    > - WARN_ON(!table);
    > + BUG_ON(!table);

    BUG_ON() is not recommended. Perhaps,

    if (!table)
    -ENODEV;

    ?

    Best regards,
    baolu

    \
     
     \ /
      Last update: 2023-05-31 05:30    [W:2.475 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site