[PATCH 6/6] isdn/gigaset: fix zero size border case in debug dump

Tilman Schmidt <[email protected]> Mon, 21 Jan 2013 22:57:21 +0100 (CET)
Newsgroups gmane.linux.kernel,gmane.linux.isdn.i4l.devel,gmane.linux.network
Message-ID <[email protected]>
If subtracting 12 from l leaves zero we'd do a zero size allocation,
leading to an oops later when we try to set the NUL terminator.

Reported-by: Dan Carpenter <[email protected]>
Signed-off-by: Tilman Schmidt <[email protected]>
CC: stable <[email protected]>
---
 drivers/isdn/gigaset/capi.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c
index 68452b7..03a0a01 100644
--- a/drivers/isdn/gigaset/capi.c
+++ b/drivers/isdn/gigaset/capi.c
@@ -248,6 +248,8 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
 		CAPIMSG_APPID(data), CAPIMSG_MSGID(data), l,
 		CAPIMSG_CONTROL(data));
 	l -= 12;
+	if (l <= 0)
+		return;
 	dbgline = kmalloc(3 * l, GFP_ATOMIC);
 	if (!dbgline)
 		return;
-- 
1.7.3.4