aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2010-07-22 19:15:09 -0400
committerDavid S. Miller <davem@davemloft.net>2010-07-23 15:36:25 -0400
commit4986f3f01aca9a332fa8e0fc9fdf3338791ee374 (patch)
tree6e721db6a2ebe00901725fd0bc1889339d736943 /drivers/s390
parentbbb822a8c032813148888fcec85e89edb17286d3 (diff)
qeth: Use memdup_user when user data is immediately copied into the allocated region.
The semantic patch that makes this change is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression from,to,size,flag; position p; identifier l1,l2; @@ - to = \(kmalloc@p\|kzalloc@p\)(size,flag); + to = memdup_user(from,size); if ( - to==NULL + IS_ERR(to) || ...) { <+... when != goto l1; - -ENOMEM + PTR_ERR(to) ...+> } - if (copy_from_user(to, from, size) != 0) { - <+... when != goto l2; - -EFAULT - ...+> - } // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Frank Blaschka <frank.blaschka@de.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/s390')
-rw-r--r--drivers/s390/net/qeth_core_main.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
index 6d51494a7f29..3a5a18a0fc28 100644
--- a/drivers/s390/net/qeth_core_main.c
+++ b/drivers/s390/net/qeth_core_main.c
@@ -3748,15 +3748,10 @@ int qeth_snmp_command(struct qeth_card *card, char __user *udata)
3748 /* skip 4 bytes (data_len struct member) to get req_len */ 3748 /* skip 4 bytes (data_len struct member) to get req_len */
3749 if (copy_from_user(&req_len, udata + sizeof(int), sizeof(int))) 3749 if (copy_from_user(&req_len, udata + sizeof(int), sizeof(int)))
3750 return -EFAULT; 3750 return -EFAULT;
3751 ureq = kmalloc(req_len+sizeof(struct qeth_snmp_ureq_hdr), GFP_KERNEL); 3751 ureq = memdup_user(udata, req_len + sizeof(struct qeth_snmp_ureq_hdr));
3752 if (!ureq) { 3752 if (IS_ERR(ureq)) {
3753 QETH_CARD_TEXT(card, 2, "snmpnome"); 3753 QETH_CARD_TEXT(card, 2, "snmpnome");
3754 return -ENOMEM; 3754 return PTR_ERR(ureq);
3755 }
3756 if (copy_from_user(ureq, udata,
3757 req_len + sizeof(struct qeth_snmp_ureq_hdr))) {
3758 kfree(ureq);
3759 return -EFAULT;
3760 } 3755 }
3761 qinfo.udata_len = ureq->hdr.data_len; 3756 qinfo.udata_len = ureq->hdr.data_len;
3762 qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL); 3757 qinfo.udata = kzalloc(qinfo.udata_len, GFP_KERNEL);