mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Thorsten Blum <blum@kernel.org>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Input: amijoy - mark amijoy_phys as __initconst
Date: Sat, 07 Nov 2026 15:19:38 -0800	[thread overview]
Message-ID: <f7574ee1581d609d45e0ff35e6d908b0@gmail.com> (raw)
In-Reply-To: <20261107174739.369375-2-blum@kernel.org>

Hi Thorsten,

On Sat, Nov 07, 2026 at 06:47:38PM +0100, Thorsten Blum wrote:
> amijoy_phys is only read by the __init function amijoy_init().
>
> Also declare amijoy_phys as const.
...
> -static char *amijoy_phys[2] = { "amijoy/input0", "amijoy/input1" };
> +static const char * const amijoy_phys[2] __initconst = {
> +	"amijoy/input0",
> +	"amijoy/input1",
> +};

While this technically works because __initconst only places the pointer
array itself into .init.rodata and leaves the string literals in .rodata,
I find it too subtle and fragile. input_register_device() retains the
dev->phys pointer for the entire lifetime of the input device, so if
anyone later turns amijoy_phys into a 2D char array to avoid pointer
indirection, the strings themselves will move into .init.rodata and
dev->phys will become a dangling pointer after init (with no warning
from modpost since the reference is inside amijoy_init()).

Could we either just mark amijoy_phys as const without __initconst (it
is only 8 bytes on m68k), or drop amijoy_phys altogether and do:

	amijoy_dev[i]->phys = i ? "amijoy/input1" : "amijoy/input0";

in amijoy_init() (which stays in .init.text anyway)?

Thanks.

-- 
Dmitry

  reply	other threads:[~2026-11-07 23:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07 17:47 Thorsten Blum
2026-11-07 23:19 ` Dmitry Torokhov [this message]
2026-11-07 23:59   ` Thorsten Blum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f7574ee1581d609d45e0ff35e6d908b0@gmail.com \
    --to=dmitry.torokhov@gmail.com \
    --cc=blum@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®