TaskBeforeDelete Trigger on Task Object:-

My requirement is Do not permit any users in any profile except 'System Administrator','Standard User' to delete tasks where Left 3 characters of the WhatId = ‘a0P’(DeleteTask__c) and Type(type__c) = ‘Test’

=====Below the trigger=====
    
    trigger TaskBeforeDelete on Task (before delete) {

      Map<Id,Profile> profileMap=new Map<Id,Profile>([SELECT Id,Name FROM Profile WHERE Name Not IN ('System Administrator','Standard User')]);
        profile p=profileMap.get(UserInfo.getprofileID());
        
        
        system.debug('Profile ==>'+p);
        
        for (Task task : Trigger.old)  {    
            
        if(task__c.equalsIgnoreCase('Test') && (p!=null)&& task.WhatId.getSObjectType() == Deletetask__c.sObjectType)           
            
            {
                task.addError('You are not permitted to delete this task');
     
            }
        
        }
        
     }

Issue is While deleting Task from other objects(like account,contact) throwing NullPointerException: Attempt to de-reference a null object error

Below is the complete Error message

    Validation Errors While Saving Record(s)There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Apex trigger TaskBeforeDelete1 caused an unexpected exception, contact your administrator: TaskBeforeDelete1: execution of BeforeDelete caused by: System.NullPointerException: Attempt to de-reference a null object: Trigger.TaskBeforeDelete1: line 11, column 1".


**Could you please help us to resolve the issue **