Skip to contentSkip to conversation

PATCH: ibm hot plug driver fix

PATCH Arjan van de Ven 1 participant 1 message Apr 30, 2003 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 24 lines · Linux Kernel Mailing List

# This patch includes the following deltas:
# ChangeSet 1.1044 -> 1.1045
# drivers/hotplug/ibmphp_ebda.c 1.6 -> 1.7
#

 ibmphp_ebda.c |   25 ++++++++++++++++++++++---
 1 files changed, 22 insertions(+), 3 deletions(-)

diff -Nru a/drivers/hotplug/ibmphp_ebda.c b/drivers/hotplug/ibmphp_ebda.c

drivers/hotplug/ibmphp_ebda.c +5 -0
@@ -608,13 +608,20 @@
 		return str;
 	default: 	
 		//2 digits number
+		str1 = (char *) kmalloc (2, GFP_KERNEL);
+		if (!str1) {
+			break;
+		}
+		memset (str, 0, 3);
 		*str1 = (char)(bit + 48);
 		strncpy (str, str1, 1);

drivers/hotplug/ibmphp_ebda.c line 626

Quoted 10 lines
drivers/hotplug/ibmphp_ebda.c +3 -1
 		memset (str1, 0, 3);
 		*str1 = (char)((var % 10) + 48);
 		strcat (str, str1);
+		kfree(str1);
 		return str;
-	}	
+	}
+	kfree(str);
 	return NULL;	
 }

ehm I'd suggest backing out this change. Not only do we have snprintf nowadays, it also corrupts memory by memsetting stuff bigger than it allocated....