NULL pointer dereference

I wrote this code for “Connecting Env to DUT” class under Basic UVM course.

I am getting a NULL pointer deference error from the Env File pasted below. Basically, when i tried to drive a value on the virtual Interface, i am getting a NULL pointer error. Not sure where i need to allocate memory for the interface? Please help!
File: ./my_env.svh, line = 20, pos = 10
Scope: worklib.my_pkg::my_env@1897_1.run_phase

DUT Interface__ —> dut_if.sv

  1 interface dut_if;
  2
  3 logic clock, reset;
  4 logic data;
  5
  6 endinterface

Env File__ —> my_env.svh

  1 class my_env extends uvm_env;
  2
  3 `uvm_component_utils(my_env)
  4
  5 //my_driver my_driver_h;
  6 virtual interface dut_if dut_vif;
  7
  8 function new(string name, uvm_component parent);
  9     super.new(name, parent);
 10 endfunction
 11
 12 function void build_phase(uvm_phase phase);
 13     super.build_phase(phase);
 14     //my_driver_h = my_driver::type_id::create("my_driver_h", this);
 15 endfunction
 16
 17 task run_phase(uvm_phase phase);
 18     phase.raise_objection(this);
 19
 20     dut_vif.data = 1;
 21     #10 dut_vif.data = 0;
 22     #10 dut_vif.data = 1;
 23     #10;
 24
 25     phase.drop_objection(this);
 26
 27 endtask-
 28
 29 endclass : my_env

Test top__

  1 class my_test extends uvm_test;
  2
  3 `uvm_component_utils(my_test)
  4
  5  my_env my_env_h;
  6  virtual interface dut_if dut_vif;
  7
  8  function new(string name, uvm_component parent);
  9     super.new(name, parent);
 10
 11     my_env_h = my_env::type_id::create("my_env_h", this);
 12
 13  endfunction
 14
 15  function void build_phase(uvm_phase phase);
 16     super.build_phase(phase);
 17
 18     if(!uvm_config_db#(virtual dut_if)::get(this, "", "dut_vif", dut_vif))
 19         `uvm_fatal(get_type_name(), "dut_if has not been instantiated")
 20 ----
 21     uvm_config_db#(virtual dut_if)::set(this, "*", "dut_vif", dut_vif);
 22  endfunction
 23
 24 endclass : my_test

Top Module__

  1 module top;
  2
  3 import uvm_pkg::*;
  4 import my_pkg::*;
  5
  6 dut_if dut_if1();
  7
  8 dut dut_inst(._if(dut_if1));
  9
 10 initial-
 11 begin
 12     uvm_config_db#(virtual dut_if)::set(null, "uvm_test_top", "dut_vif", dut_if1);
 13     run_test("my_test");
 14 end
 15
 16 endmodule : top

DUT module (Empty)__

  1 module dut(dut_if _if);
  2
  3
  4 endmodule : dut

In reply to Coppola:

You need to call uvm_config_db#(virtual dut_if)::get() inside my_env just like you did iin my_test.

Oops :-).

Thanks for the quick response, Dave. That solved the issue.