Skip to contentSkip to conversation

buggered kmalloc()

PATCH In review Al Viro 3 participants 4 messages Jul 20, 2007

Subsystems (2)
lore
Share & tools
lore

Al Viro

author
#0 lore raw

PATCH 1/1 buggered kmalloc()

---

drivers/scsi/iscsi_tcp.c +1 -1
index aebcd5f..7829ab1 100644
@@ -1885,7 +1885,7 @@ static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
 	struct sockaddr_in *sin;
 	int rc = 0, len;
 
-	addr = kmalloc(GFP_KERNEL, sizeof(*addr));
+	addr = kmalloc(sizeof(*addr), GFP_KERNEL);
 	if (!addr)
 		return -ENOMEM;
 
#1 lore raw
Quoted 7 lines · Al Viro

---

drivers/scsi/iscsi_tcp.c +0 -0
index aebcd5f..7829ab1 100644

drivers/scsi/iscsi_tcp.c static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock, · line 1890

Quoted 7 lines
drivers/scsi/iscsi_tcp.c +1 -1
@@ -1885,7 +1885,7 @@ static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
 	struct sockaddr_in *sin;
 	int rc = 0, len;
 
-	addr = kmalloc(GFP_KERNEL, sizeof(*addr));
+	addr = kmalloc(sizeof(*addr), GFP_KERNEL);
 	if (!addr)
 		return -ENOMEM;

This seems like something that would be trivial to check for in checkpatch.

Dave

Signature · 1 line
http://www.codemonkey.org.uk
author
#2 lore raw
Quoted 11 lines · Dave Jones
Quoted 10 lines · Al Viro

---

drivers/scsi/iscsi_tcp.c +0 -0
index aebcd5f..7829ab1 100644
@@ -1885,7 +1885,7 @@ static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
 	struct sockaddr_in *sin;
 	int rc = 0, len;
 
Quoted 6 lines

drivers/scsi/iscsi_tcp.c static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock, · line 1890

Quoted 4 lines
drivers/scsi/iscsi_tcp.c +1 -1
-	addr = kmalloc(GFP_KERNEL, sizeof(*addr));
+	addr = kmalloc(sizeof(*addr), GFP_KERNEL);
 	if (!addr)
 		return -ENOMEM;

This seems like something that would be trivial to check for in checkpatch.

Or just run sparse before and after - all such places stand out immediately...

#3 lore raw
In reply to Dave Jones
Quoted 11 lines · Dave Jones
Quoted 10 lines · Al Viro

---

drivers/scsi/iscsi_tcp.c +0 -0
index aebcd5f..7829ab1 100644
@@ -1885,7 +1885,7 @@ static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock,
 	struct sockaddr_in *sin;
 	int rc = 0, len;
 
Quoted 6 lines

drivers/scsi/iscsi_tcp.c static int iscsi_tcp_get_addr(struct iscsi_conn *conn, struct socket *sock, · line 1890

Quoted 4 lines
drivers/scsi/iscsi_tcp.c +1 -1
-	addr = kmalloc(GFP_KERNEL, sizeof(*addr));
+	addr = kmalloc(sizeof(*addr), GFP_KERNEL);
 	if (!addr)
 		return -ENOMEM;

This seems like something that would be trivial to check for in checkpatch.

and at runtime if we make a __GFP_VALID flag we add to all GFP_'s (and is just a few high bits in a specific pattern) and check that inside kmalloc.. since kmalloc is inline just about always it's a constant and thus compiled out check..

Signature · 2 lines
if you want to mail me at work (you don't), use arjan (at) linux.intel.com
Test the interaction between Linux and your BIOS via http://www.linuxfirmwarekit.org