From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 314AB3B2FCD; Tue, 6 Oct 2026 10:06:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791281164; cv=none; b=Ijs627wnfKrU6PND/ISLxaqN2BuqZ3Xj2bGR9YeRGjTZcZdx8y30wPvpmEoQdxWNVlnpebZJrdQnVLVXnKnAgvQhZqHAv84oamz1860folSqhF9Yeg4XsTREtWjkPCi462qx6OmEhEX7lenblZk0uJST6F+Ar2hgmJp9/GexdZA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791281164; c=relaxed/simple; bh=7ISurMb0auFlN/SwmBEY3otzpEgamf9U/yTqct3dbz4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=VvRrBLO9cScm+9W5tDa677acwT9WjMpIXhELpLBXwjlS+5D0FH7GlFhYqIZwQ8NUf4ouHTXRmTb0o6Cjxz3CeY8I3A50IIoTTP/NNhVffz6N67zwUroZwtv9uvcGb7tnp18gyjmA9U1lcU1iGGf50oKnlQhg7IlRSKCv0881qMo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=E6gnRyUw; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="E6gnRyUw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DAEA41F000FF; Tue, 6 Oct 2026 10:05:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791281162; bh=HaLuhfmI2200d0t+fAcSUnDd7yPphUbg2WEHqVSyuzk=; h=From:To:Cc:Subject:Date; b=E6gnRyUwot60DvB/vq5hbDsV2Frqdj5UvrhZLN5okcGmyTq/HpHK/ulcZDle1gTx8 mejVGKAiRZ9BSkLI0GeYY1d1IkuOzMhVI8GiK9rNwAFVjHWpIB6SJUVZjSIOz+XqCK tuhsnCnp2+XHvxm+oH+wSxPoJBmWDt+qA1uR01ltdOb9EELexBy1uYaYtdSbcZic0n 9IQ5TeG+0oBZX3EPDOs1EV81rGothWqv0dGemzJnbzHWbA3nkQmduJwyhN3G0zoRlq 9DpliCvCwUM0e10Lq7Fx04fYjyhrIxKk2+31+lXTbUUEKIqJ3POGUqgd6dtR8ZmJey 2EV3xZPjI+1Pw== From: Thorsten Blum To: Danilo Krummrich , Alice Ryhl , Alexandre Courbot , David Airlie , Simona Vetter , Gary Guo , Timur Tabi , Robin Murphy , Tim Kovalenko Cc: Thorsten Blum , nova-gpu@lists.linux.dev, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] gpu: nova-core: firmware: fwsec: use zeroed() to zero-pad buffers Date: Tue, 6 Oct 2026 12:04:36 +0200 Message-ID: <20261006100442.80432-3-blum@kernel.org> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1585; i=blum@kernel.org; h=from:subject; bh=7ISurMb0auFlN/SwmBEY3otzpEgamf9U/yTqct3dbz4=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFlHju/68HNO1poNnkbba5ZkP5rtNFlWzF1RJvf/FGPVG xd1Hpkd6yhlYRDjYpAVU2R5MOvHDN/SmspNJhE7YeawMoEMYeDiFICJrHVlZHj/raRZ2+rsM4+w C6YG7pNbP2+9ONPp8h8uh57XUV9MpTgYfrPmeG+f/3Lvj8KPNZuKOwKa50qfzWwInS1X/S7ZLT7 5MScA X-Developer-Key: i=blum@kernel.org; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit Use KVec::zeroed() to allocate the zero-padded microcode buffer and copy the bootloader code into it. Also use KVVec::zeroed() to initialize the firmware object's leading zero padding. Signed-off-by: Thorsten Blum --- drivers/gpu/nova-core/firmware/fwsec/bootloader.rs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs index ec4d92317a93..37dcd4bf4711 100644 --- a/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs +++ b/drivers/gpu/nova-core/firmware/fwsec/bootloader.rs @@ -137,10 +137,8 @@ pub(crate) fn new( .align_up(Alignment::new::<{ falcon::MEM_BLOCK_ALIGNMENT }>()) .ok_or(EINVAL)?; - let mut ucode = KVec::with_capacity(aligned_code_size, GFP_KERNEL)?; - ucode.extend_from_slice(code, GFP_KERNEL)?; - ucode.resize(aligned_code_size, 0, GFP_KERNEL)?; - + let mut ucode = KVec::zeroed(aligned_code_size, GFP_KERNEL)?; + ucode[..code.len()].copy_from_slice(code); ucode }; @@ -162,8 +160,7 @@ pub(crate) fn new( .ok_or(EOVERFLOW)? }; - let mut firmware_obj = KVVec::new(); - firmware_obj.extend_with(align_padding, 0u8, GFP_KERNEL)?; + let mut firmware_obj = KVVec::zeroed(align_padding, GFP_KERNEL)?; firmware_obj.extend_from_slice(firmware.ucode.0.as_slice(), GFP_KERNEL)?; (