Usually that means you're trying to dereference a pointer you haven't set to anything. Have you actually assigned p a value before you try to use it? On device, unlike on a PC, you can often dereference things that aren't actually valid pointers without crashing since theres no MMU watching what you're doing.