Skip to contentSkip to conversation

: fix memory leak in ppp filter ioctl error path

PATCH New Patrick McHardy 1 participant 1 message Jun 1, 2003 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : fix memory leak in ppp filter ioctl error path

This patch fixes a memory leak in ppp_ioctl,
when copy_from_user fails 'code' isn't freed.
Patch applies to both 2.4 and 2.5.

Best regards,
Patrick

# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher. # This patch includes the following deltas:
# ChangeSet 1.1248 -> 1.1249
# drivers/net/ppp_generic.c 1.19 -> 1.20
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 03/06/01 [email protected] 1.1249
# [PPP] fix memory leak in ioctl error path
# --------------------------------------------
#

drivers/net/ppp_generic.c +3 -1
diff -Nru a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c
@@ -666,8 +666,10 @@
 			if (code == 0)
 				break;
 			err = -EFAULT;
-			if (copy_from_user(code, uprog.filter, len))
+			if (copy_from_user(code, uprog.filter, len)) {
+				kfree(code);
 				break;
+			}
 			err = sk_chk_filter(code, uprog.len);
 			if (err) {
 				kfree(code);