From patchwork Sat Aug 14 23:55:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 497280 Delivered-To: patch@linaro.org Received: by 2002:a02:cf8a:0:0:0:0:0 with SMTP id w10csp559451jar; Sat, 14 Aug 2021 16:57:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfFHRUTtDO9kbvSGV7uQ04lnuD9mddoTA2qeJtWnGgf5LlMgvkVUAorW67fn3sZPTKgkfv X-Received: by 2002:a05:6402:408:: with SMTP id q8mr11381218edv.13.1628985447056; Sat, 14 Aug 2021 16:57:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628985447; cv=none; d=google.com; s=arc-20160816; b=YXr9Gn4hbb7Bp8d4VPsPbr5k1Zd7gHAOr0RyZ/ZseIXZ/dK85OH6RQQ5kzzf+SiNrq m96+3lc7QrWGsz1g5TKkpu8SdkelOn3s7yu2i2j/MDrKyoC+ULNLz1JcEDL9/3I26Owh 5NbQwq5x3nvv/aJ2na+5yeizroUIJH+7Rme1FiGleBYVYyLmAeYpdK1Vsd5tCbNltNsP mKlGvqz+0dY2paxEd6YgG91sHarB9fIDlcv6RBUIMPkffzZR3ROFxVbHZ0T9xfHfj6GM azBSl8nHI2CwdpdsKmiGunmHVAidyCicCpmOjDN78xSw2K3ybCCpp4otIrRQd8IuA+W1 8EmA== 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:cc:to:from:dkim-signature; bh=AdCTBaA9Glsngsdr3pyqLLw8trkmQt1Ycmzpqp2rJpw=; b=GAX/no7J8xB2imdWo/Pth28X7qI5/G4+rQkaov3ZABmTZT4YCM+G5OaLOwOIONSN0a YuEc8D4lDur/4NoeY3wz2NKGmfN7NVa4fPXg8vXzzb6EInIuQTIAF6Y/rjw7N34o4dUj ImE7W6ihToNsd7zvm2zqezVvoGJmNvLVi7aiVPolq2TmV3qYrzcXDlvTpFSqGnYBEFaY AuT6Th6U/eN6gIB08ahSSIumobofz9G04BMXsE98CN1f5s4c+SRw6mjdqa+sCk0y5+m8 g32Ea1WRNvO/I8LFBnmfOoJHvdAgUa2xuBxm76b9yhteKcw5NRf5eGe3pn/k7ejsQ2EV cXew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e/lW3SLN"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp20si6461394ejc.700.2021.08.14.16.57.26; Sat, 14 Aug 2021 16:57:27 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e/lW3SLN"; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233910AbhHNX5x (ORCPT + 12 others); Sat, 14 Aug 2021 19:57:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233549AbhHNX5x (ORCPT ); Sat, 14 Aug 2021 19:57:53 -0400 Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7264C0613CF for ; Sat, 14 Aug 2021 16:57:23 -0700 (PDT) Received: by mail-lf1-x12e.google.com with SMTP id g13so27024075lfj.12 for ; Sat, 14 Aug 2021 16:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AdCTBaA9Glsngsdr3pyqLLw8trkmQt1Ycmzpqp2rJpw=; b=e/lW3SLNmsYpcYIc6GcDc7pvq+Q6mq7u2fMlYfmvNMnyuJXZ2xHzVqUHrw56mZ5FDG TkUFNCiD67GNgfiGQpjVVWhq7BLlwbPkjF0/xwk7Wyq874cWU4wF1o9vleD3BLxeEwr8 b9hb0JZsZQzLyBGtuWgkcX267qIYr6X6O4DE/vkBxAXLvtGikHBngeWp+8xJ7OeHOSyt dXfBLnWqaaToDTNWFa6CPgtEsW9owDENSwByRvfi+fMNA1txKtZ6/r4nSJLH1GaY5bDa CP4+T08/TWZE3ZngvkKIKt4cw73QEC28dAcUJOjGV3ShintdAgOW039XyIFtNd8gLfct 7H6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AdCTBaA9Glsngsdr3pyqLLw8trkmQt1Ycmzpqp2rJpw=; b=Ho41GiS+LZzFtrIflR57ql3OV3styc3m3w0JoeU9uYabqSFHRKOT/Ax/uzaEnWm7t4 I8ZuNraIMeBDWa7kfPJU6UaSPboUTuMopPgTqRp3vaBk8T53ugG4q4PTh+sAnU179m0H e1ORmaav4EV98MhXMjprDi+Kb8VWVny9EpMG56yqo4vNi+ad9MZTPXtce8ssbxhYOq2o RSfbrAuhas8RplziVHO9nouRHBRHvjfnNzwzG9oc73Q5Y5i6sHVJ7cSVxmEEmGea5V7R gG79Osj3gm1x5hrzouqO2w0omUMfwga5/hpEjd9EN56Gp5GCI4xcxXPV34zy0wF5Ewvs MT/g== X-Gm-Message-State: AOAM531UDjj8NTm8t+EUSSRtdKQ+C9Wr+rb++pa6ghidAP6Ud2DOojTc dRVOz5m77vidqccDPqJdk4Ic6A== X-Received: by 2002:a05:6512:3c9d:: with SMTP id h29mr6561804lfv.600.1628985442064; Sat, 14 Aug 2021 16:57:22 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id 13sm441727ljf.110.2021.08.14.16.57.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Aug 2021 16:57:21 -0700 (PDT) From: Linus Walleij To: Michael Turquette , Stephen Boyd Cc: linux-clk@vger.kernel.org, Linus Walleij , stable@vger.kernel.org, Andrew Lunn , Chris Packham , Gregory CLEMENT , Sebastian Hesselbarth Subject: [PATCH] clk: kirkwood: Fix a clocking boot regression Date: Sun, 15 Aug 2021 01:55:14 +0200 Message-Id: <20210814235514.403426-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org Since a few kernel releases the Pogoplug 4 has crashed like this during boot: Unable to handle kernel NULL pointer dereference at virtual address 00000002 (...) [] (strlen) from [] (kstrdup+0x1c/0x4c) [] (kstrdup) from [] (__clk_register+0x44/0x37c) [] (__clk_register) from [] (clk_hw_register+0x20/0x44) [] (clk_hw_register) from [] (__clk_hw_register_mux+0x198/0x1e4) [] (__clk_hw_register_mux) from [] (clk_register_mux_table+0x5c/0x6c) [] (clk_register_mux_table) from [] (kirkwood_clk_muxing_setup.constprop.0+0x13c/0x1ac) [] (kirkwood_clk_muxing_setup.constprop.0) from [] (of_clk_init+0x12c/0x214) [] (of_clk_init) from [] (time_init+0x20/0x2c) [] (time_init) from [] (start_kernel+0x3dc/0x56c) [] (start_kernel) from [<00000000>] (0x0) Code: e3130020 1afffffb e12fff1e c08a1078 (e5d03000) This is because the "powersave" mux clock 0 was provided in an unterminated array, which is required by the loop in the driver: /* Count, allocate, and register clock muxes */ for (n = 0; desc[n].name;) n++; Here n will go out of bounds and then call clk_register_mux() on random memory contents after the mux clock. Fix this by terminating the array with a blank entry. Fixes: 105299381d87 ("cpufreq: kirkwood: use the powersave multiplexer") Cc: stable@vger.kernel.org Cc: Andrew Lunn Cc: Chris Packham Cc: Gregory CLEMENT Cc: Sebastian Hesselbarth Signed-off-by: Linus Walleij --- drivers/clk/mvebu/kirkwood.c | 1 + 1 file changed, 1 insertion(+) -- 2.31.1 Reviewed-by: Andrew Lunn diff --git a/drivers/clk/mvebu/kirkwood.c b/drivers/clk/mvebu/kirkwood.c index 47680237d0be..43b31af3a2ce 100644 --- a/drivers/clk/mvebu/kirkwood.c +++ b/drivers/clk/mvebu/kirkwood.c @@ -265,6 +265,7 @@ static const char *powersave_parents[] = { static const struct clk_muxing_soc_desc kirkwood_mux_desc[] __initconst = { { "powersave", powersave_parents, ARRAY_SIZE(powersave_parents), 11, 1, 0 }, + { }, }; static struct clk *clk_muxing_get_src(