From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0D82301486 for ; Fri, 3 Jul 2026 16:37:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783096658; cv=none; b=kO58w266D4gjg4Z01Gqk5JZbOiv0lB6V1ttsXdCx6uZ8P4jHNW7G1QLFLjktY31XNBm+X1xfrxQ2L5Ov8RHiW890bpIAY1kq9ADa1REh5HTNvlyDoy5CJpTl4v5ktEz7ojp3lut/dm7d67oHDOyId4DMot4gG6srnrLZrEJ9S5I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783096658; c=relaxed/simple; bh=W3a6RocsYvmMd7TQgrnkf5Cabz8D/s1LPH2t4/oPovk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=d6Oqr/gnlV3bvi0HvpjWszUICq6k7rUDyg8IV5Xs5wU7TtmtMsDyv7bfzYFQVp1H6aawrxp5aW8V8CK4o55Q6sN1mCRaSWe4DOAKyFLyQ1yCUJk1E1nax2oCIHt/eDpOBaijDgt1nF3AMVSJn/mFfY3FNnkvSBM3wP5bEiNj58U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UmXZQVCJ; arc=none smtp.client-ip=209.85.128.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UmXZQVCJ" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-49241dbf9c1so5865855e9.2 for ; Fri, 03 Jul 2026 09:37:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783096655; x=1783701455; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ExrdMjWEb1olxCB6ajDb+XGRteRP0J4HxD1YD52YLUI=; b=UmXZQVCJCIcF7sVMK4Px8vrgF44IEsNUQYuXqF6MH6UjH17edWzQOoRAdXm2Nnuj// p8ZYicOrxpQxEBgL6DhSrUsYkh+0zWZ95SzbSOhPttcFX+PRbYnsDhIDLBJaKKKezgzb AWdXlzSpHR93AhuegKFKJXDM7TmJ/eTnJLAYXVB1d6Mfp/VrT9LPHcZo9W+pWWOI+3Mk 5V+DMWYBRatd5ioWMQedgssHpjMerSelhvM5nX4XwiAqv61cwjDd5gNKAX/XVeEqDF4f DmxifnCn7tn3Nyn+1z2XG4jvSYo5PXpxsqdBUC95g1Glr2+O4FS3mgDNM0KDawoDsAHL fOgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783096655; x=1783701455; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=ExrdMjWEb1olxCB6ajDb+XGRteRP0J4HxD1YD52YLUI=; b=guw87q7jCLhREG+BSiPXAFuG73gQ5BQzzjuBhd0c2E9Uls9N92AY4ayY0bG+gc1fOo CI9/G0IM49c4gNu3jAV5x1d63u3hqf8wSfx5R9LZj6C77bgbSU/9MrHf0qO/ArUMrbrZ ZKlFYgv/ZHThMEamNk6JeaVHuEI9DuvRp20D5ZkZWqH2FWgQSLnPgrxG0668is8xJ1QS 8dm+VCDTotSePc7ceZhA+Gx8cO1ZrdznYjO1zTp1DoB32D+Sf/a73unthQ7bELzJ1jJ+ gXIN7F6PQQl1uZW417cJ8egMZ16mE5Z9kU51c1bGfO5ogljPqg4Rab1HW90wGxhBYrsZ 4vKA== X-Forwarded-Encrypted: i=1; AFNElJ+6DmRaM/BQI8+5XeQkn5cfWliuugwKe/fJ56Aw63/HcDlC6f7DJ4UIt+e+6oSez+mcbWH9P9GbC8NEJyk=@vger.kernel.org X-Gm-Message-State: AOJu0YxBriLheM2F5sLjxIxi9tPrZnunk7XrIGWplHh5oTcMCTzgvcq2 Hc68xezPKKiBtKKUfx09Tq4d4APq10vcWy85ivTOpi+TfbtFLC8EB1bJ X-Gm-Gg: AfdE7ckFJ1i5JDVEzEdyIeYk5OKaCvJzCu9hlARBzZoladWjQPoSFXscm7Fgm94qsCK YMnlvetNlo6V8c7v8tlhMjb3SVrnSlPyfBrm833RHFtehtHh7/bdX4cwInKZjY6IHxupIRMC6jC XEZj2ZJuRxvT4YjLg+pjZh8vKI136ogyjv0a7Dr6obQj2dcLLu+LaSolnGcpH7yiL2nSkDIVfXX Qu0HX73Uar+04IAiEFqJsJJqklItf+WeCBGAnw7z4vDxnQi8PZRZRlmxGf6uzGLRIw5PcrYUun9 cnCbJm4zrzc6Nfo5+z9sxG0zDt/nRKyVRVCD46r3rPeJPYRVJ9AwzhwNfmCOEL844yivHZI8vEM 4ifmHIYC7c6lYozR7j4ikpFjGI66dijCXUigU365zGjY7xQ3/CIbyq3970Ld8ac7MRvkAkGomh2 Ii+6f5CSTrJ0mCYiJ9HxAAjZhry0MJG2+UKNsLwr8eELNYnfxyQEQAUrXoCZTRwbUbWnMWmuRA/ eo74VdJnVk= X-Received: by 2002:a05:600c:4e11:b0:493:b549:3be0 with SMTP id 5b1f17b1804b1-493d11dd1d9mr588675e9.17.1783096654758; Fri, 03 Jul 2026 09:37:34 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-493bef23feasm177372325e9.2.2026.07.03.09.37.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2026 09:37:34 -0700 (PDT) From: David Carlier To: dan.scally@ideasonboard.com, jacopo.mondi@ideasonboard.com, mchehab@kernel.org Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, David Carlier Subject: [PATCH v2] media: mali-c55: Avoid unaligned access of AEC histogram zone weights Date: Fri, 3 Jul 2026 17:35:06 +0100 Message-ID: <20260703163506.715627-1-devnexen@gmail.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit mali_c55_params_aexp_hist_weights() packs the 225 per-zone u8 weights into the ISP registers four at a time by casting the zone_weights array to u32 and dereferencing it. The array sits at offset 10 within the parameter block, so it is only 2-byte aligned and the cast performs an unaligned 32-bit read. The Mali-C55 is only found on little-endian ARMv8 systems, where such an access does not fault, so this is not a functional bug. Copy the four bytes with memcpy() instead to avoid the unaligned access, which is a little more efficient and drops the open-coded pointer cast. No functional change intended. Signed-off-by: David Carlier --- v2: - Use memcpy() instead of get_unaligned_le32() to copy the weights. - Drop the Fixes: tag and Cc: stable; this is a cleanup, not a functional fix (the IP is little-endian ARMv8 only, where the unaligned access does not fault). Reword the commit message accordingly. drivers/media/platform/arm/mali-c55/mali-c55-params.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-params.c b/drivers/media/platform/arm/mali-c55/mali-c55-params.c index de0e9d898..832d8f49b 100644 --- a/drivers/media/platform/arm/mali-c55/mali-c55-params.c +++ b/drivers/media/platform/arm/mali-c55/mali-c55-params.c @@ -203,11 +203,11 @@ mali_c55_params_aexp_hist_weights(struct mali_c55 *mali_c55, * of overwriting other registers. */ for (unsigned int i = 0; i < 56; i++) { - val = ((u32 *)params->zone_weights)[i] - & MALI_C55_AEXP_HIST_ZONE_WEIGHT_MASK; + memcpy(&val, ¶ms->zone_weights[4 * i], 4); addr = base + MALI_C55_AEXP_HIST_ZONE_WEIGHTS_OFFSET + (4 * i); - mali_c55_ctx_write(mali_c55, addr, val); + mali_c55_ctx_write(mali_c55, addr, + val & MALI_C55_AEXP_HIST_ZONE_WEIGHT_MASK); } val = params->zone_weights[MALI_C55_MAX_ZONES - 1]; -- 2.53.0