[Mlir-commits] [mlir] 4527adc - Fix null pointer dereference in logging in mlir TransformOps (#92237)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed May 15 08:15:18 PDT 2024


Author: Daniel Kuts
Date: 2024-05-15T08:15:13-07:00
New Revision: 4527adc500ea0dc4b942a51dc7209da4ea26d9a2

URL: https://github.com/llvm/llvm-project/commit/4527adc500ea0dc4b942a51dc7209da4ea26d9a2
DIFF: https://github.com/llvm/llvm-project/commit/4527adc500ea0dc4b942a51dc7209da4ea26d9a2.diff

LOG: Fix null pointer dereference in logging in mlir TransformOps (#92237)

A variable `typeConverterOp` may be nullptr after dynamic cast. There is
a security guard for this, but during logging error message the variable
getting dereferenced.
Found with static analysis.

Added: 
    

Modified: 
    mlir/lib/Dialect/Transform/IR/TransformOps.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
index eb09f007fbca8..247759e21efb1 100644
--- a/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
+++ b/mlir/lib/Dialect/Transform/IR/TransformOps.cpp
@@ -648,13 +648,14 @@ LogicalResult transform::ApplyConversionPatternsOp::verify() {
     if (!llvm::hasSingleElement(typeConverterRegion.front()))
       return emitOpError()
              << "expected exactly one op in default type converter region";
+    Operation *maybeTypeConverter = &typeConverterRegion.front().front();
     auto typeConverterOp = dyn_cast<transform::TypeConverterBuilderOpInterface>(
-        &typeConverterRegion.front().front());
+        maybeTypeConverter);
     if (!typeConverterOp) {
       InFlightDiagnostic diag = emitOpError()
                                 << "expected default converter child op to "
                                    "implement TypeConverterBuilderOpInterface";
-      diag.attachNote(typeConverterOp->getLoc()) << "op without interface";
+      diag.attachNote(maybeTypeConverter->getLoc()) << "op without interface";
       return diag;
     }
     // Check default type converter type.


        


More information about the Mlir-commits mailing list