]> git.baikalelectronics.ru Git - kernel.git/commit
s390/qeth: overhaul L3 IP address dump code
authorJulian Wiedmann <jwi@linux.ibm.com>
Wed, 18 Dec 2019 16:34:44 +0000 (17:34 +0100)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Dec 2019 20:34:56 +0000 (12:34 -0800)
commit5dc18c28306a848ddec40adc770053f6b70c76d2
tree3c39f39c524ea73f2fd935f394fc88100606d38b
parentbe2d4844e40b46ec340cfd62256b6e74ff0ee8fc
s390/qeth: overhaul L3 IP address dump code

The current code that dumps the RXIP/VIPA/IPATO addresses via sysfs
first checks whether the buffer still provides sufficient space to hold
another formatted address.
But the maximum length of an formatted IPv4 address is 15 characters,
not 12. So we underestimate the max required length and if the buffer
was previously filled to _just_ the right level, a formatted address can
end up being truncated.

Revamp these code paths to use the _actually_ required length of the
formatted IP address, and while at it suppress a gratuitous newline.

Also use scnprintf() to format the output. In case of a truncation, this
would allow us to return the number of characters that were actually
written.

Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_l3.h
drivers/s390/net/qeth_l3_main.c
drivers/s390/net/qeth_l3_sys.c