[PATCH] NFC: nci: uart: Constify struct tty_ldisc_ops

Christophe JAILLET posted 1 patch 1 month ago
net/nfc/nci/uart.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] NFC: nci: uart: Constify struct tty_ldisc_ops
Posted by Christophe JAILLET 1 month ago
'struct tty_ldisc_ops' is not modified in this driver.

Constifying this structure moves some data to a read-only section, so
increases overall security, especially when the structure holds some
function pointers.

On a x86_64, with allmodconfig:
Before:
======
   text	   data	    bss	    dec	    hex	filename
  11454	   3352	    256	  15062	   3ad6	net/nfc/nci/uart.o

After:
=====
   text	   data	    bss	    dec	    hex	filename
  11646	   3160	    256	  15062	   3ad6	net/nfc/nci/uart.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
Compile tested only.
---
 net/nfc/nci/uart.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/nfc/nci/uart.c b/net/nfc/nci/uart.c
index 5a3aed7f84f5..aa20e8603f32 100644
--- a/net/nfc/nci/uart.c
+++ b/net/nfc/nci/uart.c
@@ -421,7 +421,7 @@ void nci_uart_set_config(struct nci_uart *nu, int baudrate, int flow_ctrl)
 }
 EXPORT_SYMBOL_GPL(nci_uart_set_config);
 
-static struct tty_ldisc_ops nci_uart_ldisc = {
+static const struct tty_ldisc_ops nci_uart_ldisc = {
 	.owner		= THIS_MODULE,
 	.num		= N_NCI,
 	.name		= "n_nci",
-- 
2.54.0
Re: [PATCH] NFC: nci: uart: Constify struct tty_ldisc_ops
Posted by David Heidelberg 1 week, 3 days ago
On 10/05/2026 22:12, Christophe JAILLET wrote:
> 'struct tty_ldisc_ops' is not modified in this driver.
> 
> Constifying this structure moves some data to a read-only section, so
> increases overall security, especially when the structure holds some
> function pointers.
> 
> On a x86_64, with allmodconfig:
> Before:
> ======
>     text	   data	    bss	    dec	    hex	filename
>    11454	   3352	    256	  15062	   3ad6	net/nfc/nci/uart.o
> 
> After:
> =====
>     text	   data	    bss	    dec	    hex	filename
>    11646	   3160	    256	  15062	   3ad6	net/nfc/nci/uart.o
> 
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> Compile tested only.
> ---
>   net/nfc/nci/uart.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Applied, thank you!

David Heidelberg