without entering too much in details, I'm writing this device driver for an fpga pci board, DMA-capable. There is a situation where the board dma-writes an ACK in memory with some data. This data is actually a pointer to a struct in memory i previously allocated, the pointer is notified to the board by using registers. So, I use the data written by the board to dereference a memory region. Since we are still in the debugging stage for this board, I cannot be totally sure about the data DMA-written, so it happens to de-reference an invalid pointer (because the data DMA-written are inconsistent).
My question is: is there a way to check a memory pointer (from kernel space) before accessing it, without generate invalid access and/or a kernel panic?