Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1200556ybl; Fri, 16 Aug 2019 10:32:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1TJg3OYbqIipysupchltZI424ury4d0eNiNwJeDMPnbKvijcQgG5g2yG2WjvMG9v7I4b/ X-Received: by 2002:a17:90a:fa95:: with SMTP id cu21mr6561247pjb.43.1565976721359; Fri, 16 Aug 2019 10:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565976721; cv=none; d=google.com; s=arc-20160816; b=Sh8eyYkypcu8d2divjYYeA3VPRyXDjDGCKM2lmJltbpAj4NEXaL4J9hHbl2XuHQ1By Xo0wBdai7DOzFZLXs0N223uOil6nUq8PKVjim08MFa2/zzYr0j7qbJaf03PP3us/K3We Qpnw05WRT7q52NTr1UBRtNNcsuRNA4Q1G4tH2kY9yaOsBCZyiVfxC2Ve81+SJTBcwSYq rneI0TcLnTBrk0Q/UoG9eyh9Jwr/SQaCk19F0FzAbsQYygDDPGoes7cEuPLzvPBK3TNV Feebs7u+GaFTOwEbR3uzbjgvVQ3a8PwwBUyhVNEpmZUDXCIlF9IP0sQPjf2VPxHqZZfY pqgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:user-agent:to:cc:from :subject:references:in-reply-to:content-transfer-encoding :mime-version:dkim-signature; bh=w4zayQbudQGRG3Pn2pTvc40NebkNZTkjsZKFGSESKl8=; b=KWbxm9PFvXsxqT0mpBaIGndNBDaFuG6naT8f12L+yKI2GoqnucH8d4wfmCcAnBklMV CKTj8zRJFRygdo1FuSHO7OmZJONCQcO8+OTwBG4gtmt+nZC8zfzZ6iLs/9vDljFYpd28 Vi20+SUo4gepyUfIBn2vtWNkeAVZm+ol7kRUwlgabp2CTe+MElhIdeFmA0x0fPJyQZDB VAjy0CHkdPnMSaRwaetrx/Bo6i/LMSsQG547kF3iG/bK2Y51droIfIlgR+XqmRrSAW7u Zhymw2NQoot/vIEKtNooM4aVVdkawIYaCXK3RXQm/sr2Istji4YTg6cpbgS8n45QpknE 5lrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PuZbq6mN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 60si4401680plb.16.2019.08.16.10.31.45; Fri, 16 Aug 2019 10:32:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PuZbq6mN; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727602AbfHPRaw (ORCPT + 99 others); Fri, 16 Aug 2019 13:30:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:53110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727347AbfHPRav (ORCPT ); Fri, 16 Aug 2019 13:30:51 -0400 Received: from kernel.org (unknown [104.132.0.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9D03C2086C; Fri, 16 Aug 2019 17:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565976650; bh=w4zayQbudQGRG3Pn2pTvc40NebkNZTkjsZKFGSESKl8=; h=In-Reply-To:References:Subject:From:Cc:To:Date:From; b=PuZbq6mNZlFjsKq9UdZ34gRKiZzR+vq1+CEGdZFnkIqYPv8qjqTL3WJ8vcE8Ldg7v wTRDveUPyUkObUtoO8i5rgLxw7yH3a8kPnCRiC1ys7xfesprL9mvx13K9LzMMWMwNv vjR8yKqEbgqqoaNN+KLdK1j3sea3dC5P/e83vfrI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In-Reply-To: <20190815223155.21384-1-martin.blumenstingl@googlemail.com> References: <20190815223155.21384-1-martin.blumenstingl@googlemail.com> Subject: Re: [PATCH RFC v1] clk: Fix potential NULL dereference in clk_fetch_parent_index() From: Stephen Boyd Cc: linux-kernel@vger.kernel.org, mturquette@baylibre.com, Martin Blumenstingl To: Martin Blumenstingl , linux-clk@vger.kernel.org User-Agent: alot/0.8.1 Date: Fri, 16 Aug 2019 10:30:49 -0700 Message-Id: <20190816173050.9D03C2086C@mail.kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Martin Blumenstingl (2019-08-15 15:31:55) > Don't compare the parent clock name with a NULL name in the > clk_parent_map. This prevents a kernel crash when passing NULL > core->parents[i].name to strcmp(). >=20 > An example which triggered this is a mux clock with four parents when > each of them is referenced in the clock driver using > clk_parent_data.fw_name and then calling clk_set_parent(clk, 3rd_parent) > on this mux. > In this case the first parent is also the HW default so > core->parents[i].hw is populated when the clock is registered. Calling > clk_set_parent(clk, 3rd_parent) will then go through all parents and > skip the first parent because it's hw pointer doesn't match. For the > second parent no hw pointer is cached yet and clk_core_get(core, 1) > returns a non-matching pointer (which is correct because we are comparing > the second with the third parent). Comparing the result of > clk_core_get(core, 2) with the requested parent gives a match. However > we don't reach this point because right after the clk_core_get(core, 1) > mismatch the old code tried to !strcmp(parent->name, NULL) (where the > second argument is actually core->parents[i].name, but that was never > populated by the clock driver). >=20 > Signed-off-by: Martin Blumenstingl > --- Applied to clk-fixes