Skip to contentSkip to conversation

staging: gpib: ni_usb: Move kfree after last use of in_data

PATCH In review Kees Bakker 2 participants 3 messages Oct 17, 2024 – Oct 19, 2024 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: gpib: ni_usb: Move kfree after last use of in_data

In ni_usb_read() there was a kfree before the last use of in_data.

---
 drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +1 -1
index 1da263676f2a..75f39e1f3ed1 100644
@@ -690,12 +690,12 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
 		kfree(in_data);
 		return parse_retval;
 	}
-	kfree(in_data);
 	if (actual_length != length - status.count) {
 		pr_err("%s: actual_length=%i expected=%li\n",
 		       __func__, actual_length, (long)(length - status.count));
 		ni_usb_dump_raw_block(in_data, usb_bytes_read);
 	}
+	kfree(in_data);
 	switch (status.error_code) {
 	case NIUSB_NO_ERROR:
 		retval = 0;
Signature · 1 line
2.47.0
maintainer
#1 lore raw
Quoted 15 lines · Kees Bakker

In ni_usb_read() there was a kfree before the last use of in_data.

---
 drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +0 -0
index 1da263676f2a..75f39e1f3ed1 100644
@@ -690,12 +690,12 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
 		kfree(in_data);
 		return parse_retval;
 	}

drivers/staging/gpib/ni_usb/ni_usb_gpib.c static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length, · line 701

Quoted 10 lines
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +1 -1
-	kfree(in_data);
 	if (actual_length != length - status.count) {
 		pr_err("%s: actual_length=%i expected=%li\n",
 		       __func__, actual_length, (long)(length - status.count));
 		ni_usb_dump_raw_block(in_data, usb_bytes_read);
 	}
+	kfree(in_data);
 	switch (status.error_code) {
 	case NIUSB_NO_ERROR:
 		retval = 0;

Does not apply to my tree, what branch did you make this against?

thanks,

greg k-h

#2 lore raw

Op 19-10-2024 om 10:00 schreef Greg KH:

Quoted 19 lines · Kees Bakker
Quoted 18 lines

In ni_usb_read() there was a kfree before the last use of in_data.

---
  drivers/staging/gpib/ni_usb/ni_usb_gpib.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +0 -1
index 1da263676f2a..75f39e1f3ed1 100644
@@ -690,12 +690,12 @@ static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length,
  		kfree(in_data);
  		return parse_retval;
  	}
-	kfree(in_data);
  	if (actual_length != length - status.count) {
  		pr_err("%s: actual_length=%i expected=%li\n",
Quoted 8 lines

drivers/staging/gpib/ni_usb/ni_usb_gpib.c static int ni_usb_read(gpib_board_t *board, uint8_t *buffer, size_t length, · line 701

Quoted 7 lines
drivers/staging/gpib/ni_usb/ni_usb_gpib.c +1 -0
  		       __func__, actual_length, (long)(length - status.count));
  		ni_usb_dump_raw_block(in_data, usb_bytes_read);
  	}
+	kfree(in_data);
  	switch (status.error_code) {
  	case NIUSB_NO_ERROR:
  		retval = 0;

Does not apply to my tree, what branch did you make this against?

It was already done in commit b0a7dfeb7df ("staging: gpib: Move free after the variable use has been completed")

Quoted 4 lines

thanks,

greg k-h