From: Dan Carpenter <dan.carpenter@oracle.com>
To: tlfalcon@linux.vnet.ibm.com
Cc: linuxppc-dev@lists.ozlabs.org
Subject: [bug report] Driver for IBM System i/p VNIC protocol
Date: Wed, 16 Nov 2016 15:25:32 +0300 [thread overview]
Message-ID: <20161116122532.GA12147@mwanda> (raw)
Hello Thomas Falcon,
The patch 032c5e82847a: "Driver for IBM System i/p VNIC protocol"
from Dec 21, 2015, leads to the following static checker warning:
drivers/net/ethernet/ibm/ibmvnic.c:2957 error_level_write()
why cast 'kstrtoul()?'
drivers/net/ethernet/ibm/ibmvnic.c
2946 static ssize_t error_level_write(struct file *file, const char __user *user_buf,
2947 size_t len, loff_t *ppos)
2948 {
2949 struct ibmvnic_fw_comp_internal *ras_comp_int = file->private_data;
2950 struct ibmvnic_adapter *adapter = ras_comp_int->adapter;
2951 int num = ras_comp_int->num;
2952 union ibmvnic_crq crq;
2953 unsigned long val;
2954 char buff[9]; /* decimal max int plus \n and \0 */
2955
2956 copy_from_user(buff, user_buf, sizeof(buff));
No error checking.
2957 val = kstrtoul(buff, 10, NULL);
This is a wrong conversion from simple_strtoul(). The code has clearly
never been tested. There are four other buggy untested calls to
kstrtoul() in this file.
2958
2959 if (val > 9)
2960 val = 9;
2961
2962 memset(&crq, 0, sizeof(crq));
2963 crq.control_ras.first = IBMVNIC_CRQ_CMD;
2964 crq.control_ras.cmd = CONTROL_RAS;
2965 crq.control_ras.correlator = adapter->ras_comps[num].correlator;
2966 crq.control_ras.op = IBMVNIC_ERROR_LEVEL;
2967 crq.control_ras.level = val;
2968 ibmvnic_send_crq(adapter, &crq);
2969
2970 return len;
2971 }
regards,
dan carpenter
next reply other threads:[~2016-11-16 12:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-16 12:25 Dan Carpenter [this message]
2016-11-16 14:35 ` [bug report] Driver for IBM System i/p VNIC protocol Thomas Falcon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161116122532.GA12147@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=tlfalcon@linux.vnet.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).