improve checks for invalid gpio pointer