Message ID | 20240110134621.17209-1-adiupina@astralinux.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-22288-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:2411:b0:101:2151:f287 with SMTP id m17csp804136dyi; Wed, 10 Jan 2024 05:56:58 -0800 (PST) X-Google-Smtp-Source: AGHT+IGO1wJdiXadqRLOhVEcQBcNf6pNTEZaKxLGlkCjG7hXjNgv7GyrFwLxfiP1WeVnZlAnhR5G X-Received: by 2002:a05:6808:1827:b0:3bc:4f4b:2876 with SMTP id bh39-20020a056808182700b003bc4f4b2876mr1325078oib.85.1704895018172; Wed, 10 Jan 2024 05:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704895018; cv=none; d=google.com; s=arc-20160816; b=uKK0BDkT0kzRRWm1tsgvN35vOnh//fldmOigkltv3s04zYDqTiN5plpgTmOho/Cmog dKXWM8d+4kxQDaCKkIcq7z6fRtoMKle/3oQzhuFt8ivLCdkxc3+0k7NmDKP6+ZfSLMY7 oaY5wogzlXKmnPXDsFjWLcSoc/L2Gt6sEk67To6GxwncVx3cGTtJvbKUZ+TxirvRfVIN SsuQ+BtmVhSGffyjlBco30NtHqrYe/sBJDbkGpUjg3pmjhyz7lLqWjdI//FMYqf+beug Tk3naHcYn+D69SdQ1pib6A+IqeEoqz/ArF3TmaAG6mQ035UISeTonmd2VkGkWdVQbYy0 0B1w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=gDH3UvOHqtfKVaJPWQ5F7elH7aZ1idLj2XkpxAK2obg=; fh=cwZx/sX9pcrxwmTb9yDZOUUiQvc0Rc8B7HnPDwjj/RI=; b=Td2sDmVS0m9J/6Zqxx7NHGMHTbLXsvWBIhd9qOhbjK+wxRNe3v+P8nUEnNYh+JRwbY W2Z9kwc9PA2ft5Dpp8tsChnL1cAjK9V7IlnbOaQV1zcUeQmVeA4xRhcJBuyksTyMEZgj 3SH+vezWyfCRsUCubNE74b+Ohup2g828t7cEK306Tw65yQuw2XwbfirHSj5M8LUM4oJa sIU/ilNhaLKTT4FsaOiuVx1hWDoPmHKdfeEl23ywN4EgzdS23H3uDNv/Q1g9NeLvQGea LGQhKpWSWYVtD6SVBzjVJo3PeYObrxlZBZZBjJKeYF566ld03FGxNlu1ysiIQPaVBxua IdDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22288-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22288-ouuuleilei=gmail.com@vger.kernel.org" Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id a9-20020a0cca89000000b006804eb57af8si4349894qvk.337.2024.01.10.05.56.58 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 05:56:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22288-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-22288-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22288-ouuuleilei=gmail.com@vger.kernel.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 ny.mirrors.kernel.org (Postfix) with ESMTPS id F11671C21ED4 for <ouuuleilei@gmail.com>; Wed, 10 Jan 2024 13:56:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B43474A984; Wed, 10 Jan 2024 13:56:32 +0000 (UTC) Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BBDED48CCE; Wed, 10 Jan 2024 13:56:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id C7B1B18692DF; Wed, 10 Jan 2024 16:46:34 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id gVFb5WEP5ieC; Wed, 10 Jan 2024 16:46:34 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 7D93F18692D1; Wed, 10 Jan 2024 16:46:34 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id lEysMdup5VIp; Wed, 10 Jan 2024 16:46:34 +0300 (MSK) Received: from rbta-msk-lt-302690.astralinux.ru (unknown [10.177.234.199]) by mail.astralinux.ru (Postfix) with ESMTPSA id 4CE9C18659DD; Wed, 10 Jan 2024 16:46:33 +0300 (MSK) From: Alexandra Diupina <adiupina@astralinux.ru> To: Nishanth Menon <nm@ti.com> Cc: Alexandra Diupina <adiupina@astralinux.ru>, Tero Kristo <kristo@kernel.org>, Santosh Shilimkar <ssantosh@kernel.org>, Michael Turquette <mturquette@baylibre.com>, Stephen Boyd <sboyd@kernel.org>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] clk: keystone: sci-clk: check devm_kmalloc_array() return value Date: Wed, 10 Jan 2024 16:46:21 +0300 Message-Id: <20240110134621.17209-1-adiupina@astralinux.ru> X-Mailer: git-send-email 2.30.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787711998837670659 X-GMAIL-MSGID: 1787711998837670659 |
Series |
clk: keystone: sci-clk: check devm_kmalloc_array() return value
|
|
Commit Message
Alexandra Diupina
Jan. 10, 2024, 1:46 p.m. UTC
devm_kmalloc_array() may return NULL, so
check return value to avoid null pointer
dereferencing
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks")
Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru>
---
drivers/clk/keystone/sci-clk.c | 3 +++
1 file changed, 3 insertions(+)
Comments
just a friendly reminder 10/01/24 16:46, Alexandra Diupina: > devm_kmalloc_array() may return NULL, so > check return value to avoid null pointer > dereferencing > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: 3c13933c6033 ("clk: keystone: sci-clk: add support for dynamically probing clocks") > Signed-off-by: Alexandra Diupina <adiupina@astralinux.ru> > --- > drivers/clk/keystone/sci-clk.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c > index 35fe197dd303..a2fa24e4f88a 100644 > --- a/drivers/clk/keystone/sci-clk.c > +++ b/drivers/clk/keystone/sci-clk.c > @@ -459,6 +459,9 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider) > tmp_clks = devm_kmalloc_array(dev, max_clks + 64, > sizeof(sci_clk), > GFP_KERNEL); > + if (!tmp_clks) > + return -ENOMEM; > + > memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk)); > if (max_clks) > devm_kfree(dev, clks);
diff --git a/drivers/clk/keystone/sci-clk.c b/drivers/clk/keystone/sci-clk.c index 35fe197dd303..a2fa24e4f88a 100644 --- a/drivers/clk/keystone/sci-clk.c +++ b/drivers/clk/keystone/sci-clk.c @@ -459,6 +459,9 @@ static int ti_sci_scan_clocks_from_fw(struct sci_clk_provider *provider) tmp_clks = devm_kmalloc_array(dev, max_clks + 64, sizeof(sci_clk), GFP_KERNEL); + if (!tmp_clks) + return -ENOMEM; + memcpy(tmp_clks, clks, max_clks * sizeof(sci_clk)); if (max_clks) devm_kfree(dev, clks);