Skip to contentSkip to conversation

binder: fix printk format for commands

PATCH In review Carlos Llamas 3 participants 3 messages May 9, 2022 – May 10, 2022 Android drivers

lore
Share & tools
lore

Carlos Llamas

author maintainer
#0 lore raw

PATCH 1/1 binder: fix printk format for commands

Make sure we use unsigned format specifier %u for binder commands as most of them are encoded above INT_MAX. This prevents negative values when logging them as in the following case:

[  211.895781] binder: 8668:8668 BR_REPLY 258949 0:0, cmd -2143260157 size 0-0 ptr 0000006e766a8000-0000006e766a8000
---
 drivers/android/binder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/android/binder.c +2 -2
index f3b639e89dd8..b4b0e4489bef 100644
@@ -3984,7 +3984,7 @@ static int binder_thread_write(struct binder_proc *proc,
 		} break;
 
 		default:
-			pr_err("%d:%d unknown command %d\n",
+			pr_err("%d:%d unknown command %u\n",
 			       proc->pid, thread->pid, cmd);
 			return -EINVAL;
 		}
@@ -4490,7 +4490,7 @@ static int binder_thread_read(struct binder_proc *proc,
 		trace_binder_transaction_received(t);
 		binder_stat_br(proc, thread, cmd);
 		binder_debug(BINDER_DEBUG_TRANSACTION,
-			     "%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n",
+			     "%d:%d %s %d %d:%d, cmd %u size %zd-%zd ptr %016llx-%016llx\n",
 			     proc->pid, thread->pid,
 			     (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
 				(cmd == BR_TRANSACTION_SEC_CTX) ?
Signature · 1 line
2.36.0.512.ge40c2bad7a-goog
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Carlos Llamas

Make sure we use unsigned format specifier %u for binder commands as most of them are encoded above INT_MAX. This prevents negative values when logging them as in the following case:

[  211.895781] binder: 8668:8668 BR_REPLY 258949 0:0, cmd -2143260157 size 0-0 ptr 0000006e766a8000-0000006e766a8000
Quoted 29 lines
---
 drivers/android/binder.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/android/binder.c +2 -3
index f3b639e89dd8..b4b0e4489bef 100644
@@ -3984,7 +3984,7 @@ static int binder_thread_write(struct binder_proc *proc,
                } break;
 
                default:
-                       pr_err("%d:%d unknown command %d\n",
+                       pr_err("%d:%d unknown command %u\n",
                               proc->pid, thread->pid, cmd);
                        return -EINVAL;
                }
@@ -4490,7 +4490,7 @@ static int binder_thread_read(struct binder_proc *proc,
                trace_binder_transaction_received(t);
                binder_stat_br(proc, thread, cmd);
                binder_debug(BINDER_DEBUG_TRANSACTION,
-                            "%d:%d %s %d %d:%d, cmd %d size %zd-%zd ptr %016llx-%016llx\n",
+                            "%d:%d %s %d %d:%d, cmd %u size %zd-%zd ptr %016llx-%016llx\n",
                             proc->pid, thread->pid,
                             (cmd == BR_TRANSACTION) ? "BR_TRANSACTION" :
                                (cmd == BR_TRANSACTION_SEC_CTX) ?
--

2.36.0.512.ge40c2bad7a-goog

Acked-by on v1 1/1
#2 lore raw
In reply to Carlos Llamas
Quoted 8 lines · Carlos Llamas

Make sure we use unsigned format specifier %u for binder commands as most of them are encoded above INT_MAX. This prevents negative values when logging them as in the following case:

[  211.895781] binder: 8668:8668 BR_REPLY 258949 0:0, cmd -2143260157 size 0-0 ptr 0000006e766a8000-0000006e766a8000

---

Looks good to me,