Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp38084441rwd; Wed, 12 Jul 2023 02:50:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlFyzDUtL/1EUfkkCfoVjBlxZUX6CfJRwhV9lodgx4jvnD/0KP3MmkL5SRdAeiQNikysGD7c X-Received: by 2002:a92:c708:0:b0:346:5a8b:53f3 with SMTP id a8-20020a92c708000000b003465a8b53f3mr9994154ilp.26.1689155451164; Wed, 12 Jul 2023 02:50:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689155451; cv=none; d=google.com; s=arc-20160816; b=m8bP5cjR3UHg09Crzyr8fIAKPXsRfJJMDDWlv9KpPvMFGxphJgEBmxZ98QejNaHtnE poXcyWo8JkjCkuWvhJLdVuIl0BIF9zS9howX88xOzOb4RjWM9fmICg2pnxWgM1bs9bOX maQpl3QSxu61j2uzhlaxL6j7GQroZFRn4X8AuvGIQZHPXeZh77GX0T63gnItsl0yY60+ gO73lqW+DlH69hJBmBSGbMsy4SOfWcUOK8mJoHxRWgav8/AqZzV6RDzU87Mit3NpyAOf plPdSo8UZrwSErYc93GP0DXnW/EpZlMWtiDYqpk1ryjwM+4WobQr2BGMIFJxoPjX8L8A Hj0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:to:from; bh=mXmAo8SNM3+cvqoHh+6giP8OfOwimtzhOg6I1Nxf3vw=; fh=UHrYfwX39AA1q4czusZlJFtSsgOVyN7bmwctWlneOnk=; b=TfcJiyqCQwI6jw7MhtZ/IrURKPMrVPNOubq5LgQ8AGWQHEPLCjhB0i0XFPaHRsW8dJ 1aDjRkSFaObKcIy7SNP41KwMzF1uZHMluDnDi3OCCIK+8jyVLcLuF5q1NYmvfW+s/q7v 5sSs3+8hk4Rjq3Bpenb4TA9RFQV879SZhLeNYMW+4VO4FmaoWkYG/NI7K7po5xXV9Hme 5dsQSTrtYEBVMsboRZDsCTrZsAmmGZTWNrHb6GVaGXYGX+n7ScN1TwtfJH4tIZfhretg I8yb3T8/F28GkZsjyykaCw92isGY43semXD/noLVR0TlCawPAFebD8kkT2aTQlT7ecPP i/rg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j64-20020a638b43000000b00534e68cc8f5si2850975pge.270.2023.07.12.02.50.38; Wed, 12 Jul 2023 02:50:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233083AbjGLJ2W (ORCPT + 99 others); Wed, 12 Jul 2023 05:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232371AbjGLJ2S (ORCPT ); Wed, 12 Jul 2023 05:28:18 -0400 X-Greylist: delayed 62 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Wed, 12 Jul 2023 02:28:15 PDT Received: from mail.aspeedtech.com (211-20-114-226.hinet-ip.hinet.net [211.20.114.226]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B590FB; Wed, 12 Jul 2023 02:28:15 -0700 (PDT) Received: from JammyHuang-PC.aspeed.com (192.168.2.181) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 12 Jul 2023 17:26:09 +0800 From: Jammy Huang To: , , , , , , , , Subject: [PATCH] media: aspeed: Fix memory overwrite if timing is 1600x900 Date: Wed, 12 Jul 2023 17:26:06 +0800 Message-ID: <20230712092606.2508-1-jammy_huang@aspeedtech.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [192.168.2.181] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,RDNS_DYNAMIC, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When capturing 1600x900, system could crash when system memory usage is tight. The size of macro block captured is 8x8. Therefore, we should make sure the height of src-buf is 8 aligned to fix this issue. Signed-off-by: Jammy Huang --- drivers/media/platform/aspeed/aspeed-video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/aspeed/aspeed-video.c b/drivers/media/platform/aspeed/aspeed-video.c index 374eb7781936..14594f55a77f 100644 --- a/drivers/media/platform/aspeed/aspeed-video.c +++ b/drivers/media/platform/aspeed/aspeed-video.c @@ -1130,7 +1130,7 @@ static void aspeed_video_get_resolution(struct aspeed_video *video) static void aspeed_video_set_resolution(struct aspeed_video *video) { struct v4l2_bt_timings *act = &video->active_timings; - unsigned int size = act->width * act->height; + unsigned int size = act->width * ALIGN(act->height, 8); /* Set capture/compression frame sizes */ aspeed_video_calc_compressed_size(video, size); @@ -1147,7 +1147,7 @@ static void aspeed_video_set_resolution(struct aspeed_video *video) u32 width = ALIGN(act->width, 64); aspeed_video_write(video, VE_CAP_WINDOW, width << 16 | act->height); - size = width * act->height; + size = width * ALIGN(act->height, 8); } else { aspeed_video_write(video, VE_CAP_WINDOW, act->width << 16 | act->height); base-commit: 2605e80d3438c77190f55b821c6575048c68268e -- 2.25.1