diff options
| author | Kees Bakker <kees@ijzerbout.nl> | 2024-10-17 22:13:31 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-10-19 11:02:08 +0300 |
| commit | cbf821e689916ef0c60b0bd8e69daa13a45f2016 (patch) | |
| tree | 0498e3fb8c84553f1c4d97ee60e75ee4578359de /drivers | |
| parent | 0edaa545afbbcd7e8ff162f9fd8852c3589d2fa6 (diff) | |
| download | linux-cbf821e689916ef0c60b0bd8e69daa13a45f2016.tar.xz | |
staging: gpib: replace dump function by print_hex_dump
It is better to use a standard (proven in use) in-kernel function that does
the same. This also solves two buffer overflow problems.
Signed-off-by: Kees Bakker <kees@ijzerbout.nl>
Link: https://lore.kernel.org/r/20241017191433.2E7BD18DAFE@bout3.ijzerbout.nl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
| -rw-r--r-- | drivers/staging/gpib/agilent_82357a/agilent_82357a.c | 14 | ||||
| -rw-r--r-- | drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 14 |
2 files changed, 2 insertions, 26 deletions
diff --git a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c index 53ec10729905..748aadc5cebc 100644 --- a/drivers/staging/gpib/agilent_82357a/agilent_82357a.c +++ b/drivers/staging/gpib/agilent_82357a/agilent_82357a.c @@ -208,20 +208,8 @@ static int agilent_82357a_receive_control_msg(struct agilent_82357a_priv *a_priv static void agilent_82357a_dump_raw_block(const u8 *raw_data, int length) { -#define RAW_BUF_SIZE 256 - int i, pos = 0; - char print_buf[RAW_BUF_SIZE]; - pr_info("hex block dump\n"); - for (i = 0; i < length; ++i) { - if (i && (i % 8 == 0)) { - pr_info("%s\n", print_buf); - pos = 0; - } - pos += snprintf(&print_buf[pos], RAW_BUF_SIZE, " %02x", raw_data[i]); - } - if (pos) - pr_info("%s\n", print_buf); + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 8, 1, raw_data, length, true); } static int agilent_82357a_write_registers(struct agilent_82357a_priv *a_priv, diff --git a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c index 330863a8be4d..571f07800c9a 100644 --- a/drivers/staging/gpib/ni_usb/ni_usb_gpib.c +++ b/drivers/staging/gpib/ni_usb/ni_usb_gpib.c @@ -355,20 +355,8 @@ static int ni_usb_parse_status_block(const u8 *buffer, struct ni_usb_status_bloc static void ni_usb_dump_raw_block(const u8 *raw_data, int length) { -#define RAW_BUF_SIZE 256 - int i, pos = 0; - char print_buf[RAW_BUF_SIZE]; - pr_info("hex block dump\n"); - for (i = 0; i < length; ++i) { - if (i && (i % 8 == 0)) { - pr_info("%s\n", print_buf); - pos = 0; - } - pos += snprintf(&print_buf[pos], RAW_BUF_SIZE, " %02x", raw_data[i]); - } - if (pos) - pr_info("%s\n", print_buf); + print_hex_dump(KERN_INFO, "", DUMP_PREFIX_NONE, 8, 1, raw_data, length, true); } static int ni_usb_parse_register_read_block(const u8 *raw_data, unsigned int *results, |
