Skip to contentSkip to conversation

staging: greybus: add logging statement when kfifo_alloc fails

PATCH In review Keyur Patel 2 participants 4 messages Jul 10, 2019 – Jul 11, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: greybus: add logging statement when kfifo_alloc fails

Added missing logging statement when kfifo_alloc fails, to improve debugging.

---
 drivers/staging/greybus/uart.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/greybus/uart.c +3 -1
index b3bffe91ae99..86a395ae177d 100644
@@ -856,8 +856,10 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
 
 	retval = kfifo_alloc(&gb_tty->write_fifo, GB_UART_WRITE_FIFO_SIZE,
 			     GFP_KERNEL);
-	if (retval)
+	if (retval) {
+		pr_err("kfifo_alloc failed\n");
 		goto exit_buf_free;
+	}
 
 	gb_tty->credits = GB_UART_FIRMWARE_CREDITS;
 	init_completion(&gb_tty->credits_complete);
Signature · 1 line
2.22.0
#1 lore raw
Quoted 13 lines · Keyur Patel

Added missing logging statement when kfifo_alloc fails, to improve debugging.

---
 drivers/staging/greybus/uart.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/greybus/uart.c +0 -0
index b3bffe91ae99..86a395ae177d 100644

drivers/staging/greybus/uart.c static int gb_uart_probe(struct gbphy_device *gbphy_dev, · line 862

Quoted 8 lines
drivers/staging/greybus/uart.c +3 -1
@@ -856,8 +856,10 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
 
 	retval = kfifo_alloc(&gb_tty->write_fifo, GB_UART_WRITE_FIFO_SIZE,
 			     GFP_KERNEL);
-	if (retval)
+	if (retval) {
+		pr_err("kfifo_alloc failed\n");
 		goto exit_buf_free;
+	}

You should have already gotten an error message from the log if this fails, from the kmalloc_array() call failing, right?

So why is this needed? We have been trying to remove these types of messages and keep them in the "root" place where the failure happens.

thanks,

greg k-h

#2 lore raw
Quoted 26 lines · Greg Kroah-Hartman
Quoted 13 lines · Keyur Patel

Added missing logging statement when kfifo_alloc fails, to improve debugging.

---
 drivers/staging/greybus/uart.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/greybus/uart.c +0 -0
index b3bffe91ae99..86a395ae177d 100644

drivers/staging/greybus/uart.c static int gb_uart_probe(struct gbphy_device *gbphy_dev, · line 862

Quoted 8 lines
drivers/staging/greybus/uart.c +3 -1
@@ -856,8 +856,10 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
 
 	retval = kfifo_alloc(&gb_tty->write_fifo, GB_UART_WRITE_FIFO_SIZE,
 			     GFP_KERNEL);
-	if (retval)
+	if (retval) {
+		pr_err("kfifo_alloc failed\n");
 		goto exit_buf_free;
+	}

You should have already gotten an error message from the log if this fails, from the kmalloc_array() call failing, right?

Quoted 6 lines

So why is this needed? We have been trying to remove these types of messages and keep them in the "root" place where the failure happens.

thanks,

greg k-h

Didn't notice that. I agree that this will result only into redundancy. Quick look over files reveal that there are multiple places where people are using print statements after memory allocation fails. Should I go ahead and send patches to remove those
redundant print statements?

Sorry, if you're receiving this message again.

Thnaks.
Keyur Patel

#3 lore raw
Quoted 32 lines · Keyur Patel
Quoted 31 lines · Greg Kroah-Hartman
Quoted 13 lines · Keyur Patel

Added missing logging statement when kfifo_alloc fails, to improve debugging.

---
 drivers/staging/greybus/uart.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/staging/greybus/uart.c +0 -0
index b3bffe91ae99..86a395ae177d 100644

drivers/staging/greybus/uart.c static int gb_uart_probe(struct gbphy_device *gbphy_dev, · line 862

Quoted 8 lines
drivers/staging/greybus/uart.c +3 -1
@@ -856,8 +856,10 @@ static int gb_uart_probe(struct gbphy_device *gbphy_dev,
 
 	retval = kfifo_alloc(&gb_tty->write_fifo, GB_UART_WRITE_FIFO_SIZE,
 			     GFP_KERNEL);
-	if (retval)
+	if (retval) {
+		pr_err("kfifo_alloc failed\n");
 		goto exit_buf_free;
+	}

You should have already gotten an error message from the log if this fails, from the kmalloc_array() call failing, right?

So why is this needed? We have been trying to remove these types of messages and keep them in the "root" place where the failure happens.

thanks,

Quoted 7 lines
Quoted 1 line

greg k-h

Didn't notice that. I agree that this will result only into redundancy. Quick look over files reveal that there are multiple places where people are using print statements after memory allocation fails. Should I go ahead and send patches to remove those
redundant print statements?

It all depends on where in the kernel those are. Some subsystems want minor cleanups like this, but most do not. So unless the issue you find is in the drivers/staging/ directory, I would not worry about it.

thanks,

greg k-h