Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/net: fix format string mismatches

cppcheck blamed some issues in drivers/s390/net/...
They are fixed here.

Signed-off-by: Ursula Braun <ursula.braun@de.ibm.com>
Signed-off-by: Frank Blaschka <blaschka@linux.vnet.ibm.com>
Reported-by: Toralf Foerster <toralf.foerster@gmx.de>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Ursula Braun and committed by
David S. Miller
a68be015 e95051ff

+19 -10
+9 -5
drivers/s390/net/ctcm_sysfs.c
··· 34 34 struct device_attribute *attr, const char *buf, size_t count) 35 35 { 36 36 struct net_device *ndev; 37 - int bs1; 37 + unsigned int bs1; 38 38 struct ctcm_priv *priv = dev_get_drvdata(dev); 39 + int rc; 39 40 40 41 ndev = priv->channel[CTCM_READ]->netdev; 41 42 if (!(priv && priv->channel[CTCM_READ] && ndev)) { ··· 44 43 return -ENODEV; 45 44 } 46 45 47 - sscanf(buf, "%u", &bs1); 46 + rc = sscanf(buf, "%u", &bs1); 47 + if (rc != 1) 48 + goto einval; 48 49 if (bs1 > CTCM_BUFSIZE_LIMIT) 49 50 goto einval; 50 51 if (bs1 < (576 + LL_HEADER_LENGTH + 2)) ··· 146 143 static ssize_t ctcm_proto_store(struct device *dev, 147 144 struct device_attribute *attr, const char *buf, size_t count) 148 145 { 149 - int value; 146 + int value, rc; 150 147 struct ctcm_priv *priv = dev_get_drvdata(dev); 151 148 152 149 if (!priv) 153 150 return -ENODEV; 154 - sscanf(buf, "%u", &value); 155 - if (!((value == CTCM_PROTO_S390) || 151 + rc = sscanf(buf, "%d", &value); 152 + if ((rc != 1) || 153 + !((value == CTCM_PROTO_S390) || 156 154 (value == CTCM_PROTO_LINUX) || 157 155 (value == CTCM_PROTO_MPC) || 158 156 (value == CTCM_PROTO_OS390)))
+9 -4
drivers/s390/net/lcs.c
··· 1943 1943 lcs_portno_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 1944 1944 { 1945 1945 struct lcs_card *card; 1946 - int value; 1946 + int value, rc; 1947 1947 1948 1948 card = dev_get_drvdata(dev); 1949 1949 1950 1950 if (!card) 1951 1951 return 0; 1952 1952 1953 - sscanf(buf, "%u", &value); 1953 + rc = sscanf(buf, "%d", &value); 1954 + if (rc != 1) 1955 + return -EINVAL; 1954 1956 /* TODO: sanity checks */ 1955 1957 card->portno = value; 1956 1958 ··· 1999 1997 lcs_timeout_store (struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 2000 1998 { 2001 1999 struct lcs_card *card; 2002 - int value; 2000 + unsigned int value; 2001 + int rc; 2003 2002 2004 2003 card = dev_get_drvdata(dev); 2005 2004 2006 2005 if (!card) 2007 2006 return 0; 2008 2007 2009 - sscanf(buf, "%u", &value); 2008 + rc = sscanf(buf, "%u", &value); 2009 + if (rc != 1) 2010 + return -EINVAL; 2010 2011 /* TODO: sanity checks */ 2011 2012 card->lancmd_timeout = value; 2012 2013
+1 -1
drivers/s390/net/qeth_l3_main.c
··· 63 63 int qeth_l3_string_to_ipaddr4(const char *buf, __u8 *addr) 64 64 { 65 65 int count = 0, rc = 0; 66 - int in[4]; 66 + unsigned int in[4]; 67 67 char c; 68 68 69 69 rc = sscanf(buf, "%u.%u.%u.%u%c",