From nobody Mon Sep 28 11:40:21 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 97954390998 for ; Fri, 21 Aug 2026 23:58:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787356733; cv=none; b=p30SOOlXkCPyeKKDMLWKcrHwg4Ukh06Td7wnTBPicdcUMrk2lRkmgcE+nm7CNXOz8wVbzwhkddhJSuDDe3go5jiebJ+Re6v+C/uLKkswkEIs9MkYEzoRzIwOuZi+21UcNqX1hnGTto1mhqGINR24IBHACCEYUMQMWuhVwtbkSBs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1787356733; c=relaxed/simple; bh=TuE2c0iZfNH1S7lUSfDr5VyClYyuD1z0aAEc0nKSpIU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ua0LCS99V1OlBuRfgfVb/xDCJcP7oY/WPXQ4gbYKQSuiLCoJTxA/yC4OJySGyosRXi2zGa1jqy/AaS4FRljLlm7aGGxPpCgTA/J4dYADUp38F88rXR/s8sJeDMuWEKvqY0Vq8K0SODaJoZ3DcfB/zs8UsWPo5Sj3Uj9kFOiWvUg= 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=As7C00g6; arc=none smtp.client-ip=209.85.214.178 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="As7C00g6" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2cc891373e0so18508525ad.2 for ; Fri, 21 Aug 2026 16:58:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1787356732; x=1787961532; 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:content-type; bh=yfADMu2KMEVkqXjLqt2cOsbz+PXBarm0PZCvaHp/dFA=; b=As7C00g6TpzJja9PyFzEBDQ4XYuH/J2UU3OfZ2wlejhe2xaLMHUq/rRfyEdiNhHUI+ U7Lm812jIMzMGuGxUeWQOjTVixIFAnONyRFix0Z5ysg798C8ljM/Sy03QEQmMldxv5Kk yMzUA9Of1gD6vN73GUJMrx5Owaz9dzRVYsfk1T4eB7dyJ8LgmJ5uBWsYZ0tmGampUHOJ liilIZH/qdiqhMYLHRJPxl7Ow+kP+AKXfTmQeGuQxC3YFNcn+nJf6ltNubNDN6d4jFnv Cr2z+Z2s9qIQEyeZqhNvFFruxvqJtOgcdb5kFAhBLtmD4gPEWSsYWIrv3dmVDicdWzFQ 8Opw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1787356732; x=1787961532; 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:content-type; bh=yfADMu2KMEVkqXjLqt2cOsbz+PXBarm0PZCvaHp/dFA=; b=SMajMYYkcHgtZIRmX0P0q/1oJI0WGx6Yk9Zi+799rprBloN7nzmGSnV8qUgPCx5dUW BXLNQiYGgUHoyNGxG2e06P8yFU2sDKvAe5AIJ7Nxw8pqA/bpkX3JkhhUFVTz4mdJ1kY0 mMqj9s8lsvLRo1aygQ/n52Z8+GRo4xo9oiY2G5cKXMZck/qbDEK7tvBhtMIPHFzhRB5T XpsfkmdhcdeZeaqx29ZREt4kFf6Qx9J23aDSLEtZQCGEkF+6sdeRV8jf2n55ohtizSad THH92DkK9vJeBIrvJQDIF09+pgO6c5X65WeuHRunFKUQzSx0aZmB1IWLO/3gcxN60+my cXQg== X-Forwarded-Encrypted: i=1; AHgh+RpozI2i46NNf8BuVKGCc7CIqhINEUR9ri1qIfT8noL76rkiJ5UK7CqMZ7pv1wH75evYUE9rfD1vBezFWSA=@vger.kernel.org X-Gm-Message-State: AFuF++kx6spMzwrt5p3xPrZkCeROKd2eF1nweOpPo8KjducgEx4NQSCa ShkQNm69ojXGkdIU1lCmnRthcAJgIQ4fb13C3kpii26gFhaJYvPgPBAg X-Gm-Gg: AR+sD133/idsAzlU998K4iNOiKKsQCyp4rFL1siUboL8C+hKAUexNBVMSRi1yAHKy3W GDpgA3lCAyysKQxT67arVZgtOAN6geukjZBaioNMnJp81SB5RzOmDRlp1TNCOPfWsmWzNfRokqn MWiWToH6TB0oSt22FrT8fS+Pi0SnKn69ZijIbkOjNbCK851Yz7Fp5y4YcU1MPavMYezKFYGaDjx MOvy3suqL24SkeM8w2byBE3s2lWo2KAy6Cy9IWIHR8809SyBGW1nH5VMgl9xMdev9D38ll+MnhY uilYXNTCf5Ks2ODwmiv9JmPyOYq4ap4SvI8xYBMewuSdQacpnQkX2FhCyXZIqT9vHhFoPq/Pcgm Ibt6bw3FyFvZT86Klqbk8DJecDy7U7GF94PlUGITJM2pMlp1aNgzcEF3k1V3Uk0hGoGlw//Docl fGEBCIe3bDT7rWsTeohHNe6fxyxtBYjoIMSqGqOIVjGhbCpj3LF0wQeQKtd4fkrI0suGfdiLxmH DdA2X/NyMaruHu3y7c2EsB858ePr2Ju2Do9ZY7IE/LRze6tZRh6 X-Received: by 2002:a17:903:a90:b0:2c0:a555:80d6 with SMTP id d9443c01a7336-2d670b60ceemr33715055ad.2.1787356731807; Fri, 21 Aug 2026 16:58:51 -0700 (PDT) Received: from hanzj-mi.. (ec2-99-79-140-187.ca-central-1.compute.amazonaws.com. [99.79.140.187]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2d6768b9c0fsm196965ad.59.2026.08.21.16.58.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Aug 2026 16:58:51 -0700 (PDT) From: hanzhijian To: Daniel Palmer , Romain Perier , Michael Turquette , Stephen Boyd Cc: Brian Masney , linux-arm-kernel@lists.infradead.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, hanzhijian Subject: [PATCH] clk: mstar: msc313-mpll: fix off-by-one in clock array allocation Date: Sat, 22 Aug 2026 07:58:37 +0800 Message-ID: <20260821235837.2341179-1-hanzhijian1991@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The hws array of mpll->clk_data is allocated with struct_size() using ARRAY_SIZE(output_dividers) as the element count, giving it 7 elements. But the probe function stores the MPLL clock at hws[0] and one fixed-factor clock for each output divider at hws[i + 1] for i in [0, ARRAY_SIZE(output_dividers)), writing 8 elements in total. The final write to hws[7] is past the end of the allocation. clk_data->num is also set to NUMOUTPUTS (8), so the clock framework reads hws[0..7], again accessing hws[7] out of bounds. Use NUMOUTPUTS as the element count so the allocation matches the number of clocks actually stored and exposed. Found by smatch: drivers/clk/mstar/clk-msc313-mpll.c:134 msc313_mpll_probe() error: buffer overflow 'mpll->clk_data->hws' 7 <=3D 7 Signed-off-by: hanzhijian --- drivers/clk/mstar/clk-msc313-mpll.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/clk/mstar/clk-msc313-mpll.c b/drivers/clk/mstar/clk-ms= c313-mpll.c index 61beb4e87..bd45aa0ae 100644 --- a/drivers/clk/mstar/clk-msc313-mpll.c +++ b/drivers/clk/mstar/clk-msc313-mpll.c @@ -105,7 +105,7 @@ static int msc313_mpll_probe(struct platform_device *pd= ev) return PTR_ERR(mpll->loop_div_second); =20 mpll->clk_data =3D devm_kzalloc(dev, struct_size(mpll->clk_data, hws, - ARRAY_SIZE(output_dividers)), GFP_KERNEL); + NUMOUTPUTS), GFP_KERNEL); if (!mpll->clk_data) return -ENOMEM; =20 --=20 2.43.0