Received: by 2002:ab2:3141:0:b0:1ed:23cc:44d1 with SMTP id i1csp635337lqg; Fri, 1 Mar 2024 16:52:41 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW9Mf06sECcFEmRgeXAQz3yoHIykMetXQuLlJprgxX5gyh/rbXfTekxwEh55EmRP3B18DyhUyhPMKgY7nrXbxqUCEvw0tIA7cn5WTawIA== X-Google-Smtp-Source: AGHT+IGjULBzVPijvnHIVrEq8nPGI+6cw8PR1XqtVHM9CWXxLjLzU/rErA4kVQGa5Al6LJFHLRgv X-Received: by 2002:a17:906:e248:b0:a43:cf73:6451 with SMTP id gq8-20020a170906e24800b00a43cf736451mr2986692ejb.8.1709340760958; Fri, 01 Mar 2024 16:52:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709340760; cv=pass; d=google.com; s=arc-20160816; b=r8ITrcOgnTzAEcreVOby7ltaHBsOCH0WYXQcgx6JjYAdmpdkX0u7AAnsfaTPbDgSgY nCVeyX71/kMIdzCVZrjNyXo1NVNcA+pNlaNOtwpNZiSBi0m19bLXeb6bZrqX5PqDWk6x FCsau5BkH8yREV4L8JtVQwHYj6TU1E3UZ7llhIxN819kWcoCnLeOCn0fNxQxBpOtridn XExDl8z9z3k19V7yc4D7qfbxoGVigQYthKIbvEIb++DH04T+bqLgaSjRqXtma0uHwF9B klNlWpaKlkEDqfahecyX4OIcr9FjjXX1SMI3Me8kX7qmFrewilmHFb5VlnWwp6rBDNFH j54Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=/abXWgtHmlIb9XxgX5gbRZA6M3LUdmvdJ04zpHwkRbw=; fh=290Usqmf+OFVHYOw3XVbikicMu6UHvkJPuMGvmP27TQ=; b=Z0Cr07Efah8vog5Br3dF+38tfFvt+p8p5hxHCd0uwdBjDnk6ETQq/KgKX2UEajYO+G J1OlqcIiuCXxeegVs1xCOhR5xfCmPCycDWv55dftxZcNky4zHFdRh7UkXhgh5v2DOxEj U7LkXpUpFsWHPvXFzJ57cehsTxPmNgXGdUPT3NCoI2m2FMe12J0UNzUuyYI/pIGyu5DI 1oh3yYfTtO3i7kB73R80H/wsNcNrLEWnubay/ItqhDQXbLBWoWZK/JRArJya/rtGvVia EkJ5MZwAtg948WsUMneOZmUvb37xD4xTsyND2d6qYVnh9GX+hpRfvtVXzqu3JAv6vAXF sSmg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ciwdgtcx; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-89271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id k20-20020a1709061c1400b00a441c25df84si1855609ejg.738.2024.03.01.16.52.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 16:52:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-89271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Ciwdgtcx; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-89271-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-89271-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 84A021F22F1B for ; Sat, 2 Mar 2024 00:52:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 43E626FCA; Sat, 2 Mar 2024 00:52:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ciwdgtcx" Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (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 98CA415B3 for ; Sat, 2 Mar 2024 00:52:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709340743; cv=none; b=HQVoC/bgKgdWCP3SkG3KE3A4emfcc3eI/SYZEl7zpeHcDFgmOtIhC0BzKviE7y0TxoIMkU+mPAvBd2Q+TlMzI3kt7kHrzMzPO0kiFsG2brFQmD1gt8PsD1B7eaKteuPwN9uztH+lGANEYK56cdTXshWGolZp+LFU2Dq38zEKj5w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709340743; c=relaxed/simple; bh=i9zNt6rOlk75HZazBVwuQFbrGUUh1ujpF0qjhh1iKXA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IXZAgvtfWJh6KJb9dtLk16A1dW20ch+2lehJs8nRIePmSiOCJ/V9llMUzufZ11uvBMWmvlKhYSDZjXNkoQsp4QG04x0HpnC7OYvxdGHIcQ+FVYXyNEvZEJX95Wm/3b97XYomz8sY+31qYkBxSGIvfpWwvILWoCtJyXyUYtsm5ZQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=Ciwdgtcx; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-412d29057a9so726335e9.1 for ; Fri, 01 Mar 2024 16:52:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1709340740; x=1709945540; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/abXWgtHmlIb9XxgX5gbRZA6M3LUdmvdJ04zpHwkRbw=; b=Ciwdgtcxa/fSIwfjDv5PEpnA12SP3Ng9piagaR7l7Ovt6t65i3JcZOvJqi/zFXd29D b71KOEy3u2LsjJFBCCJRlM8pH7oe6DSv3KW68ycHfPxaIenn2tq3MBfDGeefdR9SFfhx tw3QZtzDdma3CBg6Ucj8l3+a/H7jDXEABjR2BUZ2fsc+dNoZmO4+XsgPQNKobxKKh9ld 4NCIJfHOTrlvqKdTengK9/okDZjvdrSwhALXHhvgiZdYTVYK4ESkbh6VPxa91ufNVi/+ p1jQg6C9VVudSqxgOxZYa5ZTiTR2uTaeyFdA8/8PzZ47iqyy4G4vRZM1o2msMKo2eRyy kboQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709340740; x=1709945540; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/abXWgtHmlIb9XxgX5gbRZA6M3LUdmvdJ04zpHwkRbw=; b=ncF67h+OVuLVYGVE+4+LF+4BltV6h8hrEvC3cu9pdc85QP6ngEFwxCmbCeJeD/xKMZ thOaqk2GnA51ktW8a1NoLwttymSUjCS/GL2RM8uGciYV/87cvMW5o150uFul5enuRFNI gHvHL144OeclB6wK23pIzgYm1ZSHUz8BdwyL1cKZlZnQl/gM5mhYZh6EP0+Ukoutlkf0 d4SOsmLwiPRV1iDG7yayfZPwTaO9EaEREd1hO4c7JlmqpLP2KHUp/xlJyhVDlphs7q10 HpspleRr4YJ2meaT+r3JpSS9U9/0hIQJoi2p0ZGlFGEDp5Bv9yMMiKszSJeamCJbnpm0 7jBA== X-Forwarded-Encrypted: i=1; AJvYcCWCVczW6dNCUi56oreu5vqIsZF/QgoarkWiz1pWQm+/tyUmpWSjXfL3YmviC+PBPtFuFExoYAcuft7sDrrM/1qr48E+FN6eVDQxp1br X-Gm-Message-State: AOJu0YzERZYoN/qLRJvGfyF3SsbqxxjnTBS1uflKb+81BbLo9CaSbCM8 cuRIyJydlGOfICoHISmk1x1sc9aeMxZvE8qEG0X5KiCH6gkKg3qeFc5G5j1pskM= X-Received: by 2002:a05:600c:4448:b0:412:b0d3:49d9 with SMTP id v8-20020a05600c444800b00412b0d349d9mr3246722wmn.9.1709340739907; Fri, 01 Mar 2024 16:52:19 -0800 (PST) Received: from [127.0.1.1] ([176.61.106.68]) by smtp.gmail.com with ESMTPSA id f15-20020adffccf000000b0033dedd63382sm5865501wrs.101.2024.03.01.16.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 16:52:19 -0800 (PST) From: Bryan O'Donoghue Date: Sat, 02 Mar 2024 00:52:14 +0000 Subject: [PATCH 1/2] clk: Fix clk_core_get NULL dereference Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240302-linux-next-24-03-01-simple-clock-fixes-v1-1-25f348a5982b@linaro.org> References: <20240302-linux-next-24-03-01-simple-clock-fixes-v1-0-25f348a5982b@linaro.org> In-Reply-To: <20240302-linux-next-24-03-01-simple-clock-fixes-v1-0-25f348a5982b@linaro.org> To: Michael Turquette , Stephen Boyd , Bjorn Andersson , Konrad Dybcio , Rajendra Nayak , Abel Vesa Cc: linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, Bryan O'Donoghue X-Mailer: b4 0.14-dev It is possible for clk_core_get to dereference a NULL in the following sequence: clk_core_get() of_clk_get_hw_from_clkspec() __of_clk_get_hw_from_provider() __clk_get_hw() __clk_get_hw() can return NULL which is dereferenced by clk_core_get() at hw->core. Prior to commit dde4eff47c82 ("clk: Look for parents with clkdev based clk_lookups") the check IS_ERR_OR_NULL() was performed which would have caught the NULL. Reading the description of this function it talks about returning NULL but that cannot be so at the moment. Update the function to check for hw before dereferencing it and return NULL if hw is NULL. Fixes: dde4eff47c82 ("clk: Look for parents with clkdev based clk_lookups") Signed-off-by: Bryan O'Donoghue --- drivers/clk/clk.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index a3bc7fb90d0f..25371c91a58f 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -418,6 +418,9 @@ static struct clk_core *clk_core_get(struct clk_core *core, u8 p_index) if (IS_ERR(hw)) return ERR_CAST(hw); + if (!hw) + return NULL; + return hw->core; } -- 2.43.0