diag: Add safeguards to prevent Integer Underflow and Memory Leak

At certain areas in the Diag driver, Integer overflow can occur.
Also, there is a possible memory leak in when a user space
program makes a ioctl call. This change fixes these issues.

Change-Id: I37e2b2d1f02983011a1db5f163354af4090f76f0
CRs-Fixed: 416995
CRs-Fixed: 416758
CRs-Fixed: 416953
Signed-off-by: Ravi Aravamudhan <aravamud@codeaurora.org>
3 files changed