Skip to content

Commit 21b34a3

Browse files
nathanchanceUlf Hansson
authored andcommitted
memstick: core: Zero initialize id_reg in h_memstick_read_dev_id()
A new warning in clang [1] points out that id_reg is uninitialized then passed to memstick_init_req() as a const pointer: drivers/memstick/core/memstick.c:330:59: error: variable 'id_reg' is uninitialized when passed as a const pointer argument here [-Werror,-Wuninitialized-const-pointer] 330 | memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, &id_reg, | ^~~~~~ Commit de182cc ("drivers/memstick/core/memstick.c: avoid -Wnonnull warning") intentionally passed this variable uninitialized to avoid an -Wnonnull warning from a NULL value that was previously there because id_reg is never read from the call to memstick_init_req() in h_memstick_read_dev_id(). Just zero initialize id_reg to avoid the warning, which is likely happening in the majority of builds using modern compilers that support '-ftrivial-auto-var-init=zero'. Cc: stable@vger.kernel.org Fixes: de182cc ("drivers/memstick/core/memstick.c: avoid -Wnonnull warning") Link: llvm/llvm-project@00dacf8 [1] Closes: ClangBuiltLinux#2105 Signed-off-by: Nathan Chancellor <nathan@kernel.org> Link: https://lore.kernel.org/r/20250715-memstick-fix-uninit-const-pointer-v1-1-f6753829c27a@kernel.org Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent ff09b71 commit 21b34a3

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/memstick/core/memstick.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ EXPORT_SYMBOL(memstick_init_req);
324324
static int h_memstick_read_dev_id(struct memstick_dev *card,
325325
struct memstick_request **mrq)
326326
{
327-
struct ms_id_register id_reg;
327+
struct ms_id_register id_reg = {};
328328

329329
if (!(*mrq)) {
330330
memstick_init_req(&card->current_mrq, MS_TPC_READ_REG, &id_reg,

0 commit comments

Comments
 (0)