Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp4465824ybi; Mon, 27 May 2019 19:22:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqwa3l2RyGShDRRwRGNEegy3QwVOnBH8HOO16DJtnqXsqbNVOmTmeXY43pEqszpkctGJflDG X-Received: by 2002:a63:e603:: with SMTP id g3mr20468195pgh.167.1559010126543; Mon, 27 May 2019 19:22:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559010126; cv=none; d=google.com; s=arc-20160816; b=bUpz0bP3O0Hbp1Ous0Q3/prE5JXmDvkNNkETN0zCfpVXcHy74pxSJzor7E3P/TeJIf 6mDYDy0vnoJ2zutpX2DS8bSOtJAuRQ++FuBiEQF48FgyiORSv9NFF9fsb5Svw2ejnUAA IjX4NVaVetgLdqOWT8YY1v+QCJbTOtJOWMIVIniYWbpU5iww2LIb7uAxdSH9JeGRDo8+ ixHItSxenjXGRAM4ixGLgLmRU+ZYp+u7I8P66yI6VekXVtPWG1OX4DTst4/LPjIn2s4D ff7QrWVeXE+QOGvvvuiPIN+HTCZVnCWYUfqbs2frgWbPfOrxLIhbFnp9AJ4r0/n2cdlX sdpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=ElrAVYgD/pSAQ+6wQeGjrI42nh6rZoHmZOAfKuzcT8A=; b=yNUcs34bw2UDVkYs7XZWPMEjwUE4anLGFjfIglkf4toC1LSIcXsczdaaYFoCqS9vmv EoVDY8yuH/iaj4NCHeDCHGD75kOp0MYvxPqlv/X6bZrAb9I8kUi6Z977TDxkfWxTnTAR Okf/asENnRZeqxLy1CZ5tERy6blzTGG6ESBDeomoCob5+vXTpeXD3ABsA0NThKjHd1Lh yDNdXUp2gLhNaOc6r3sZo3LcdvnMk8aprCQzhsdZCPD3NmhvEzHVGZGaTfD3OKO81QFR 8c/5PzfujcWBSSczb0vPunzWeejEyWnJYHAG/FSv9zrkCfKVgghe6QnrVrWHPN28H5CP yFxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=vIc21H9T; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m98si1387372pjb.2.2019.05.27.19.21.51; Mon, 27 May 2019 19:22:06 -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=@gmail.com header.s=20161025 header.b=vIc21H9T; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728017AbfE1CTP (ORCPT + 99 others); Mon, 27 May 2019 22:19:15 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40843 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727763AbfE1CTO (ORCPT ); Mon, 27 May 2019 22:19:14 -0400 Received: by mail-pf1-f195.google.com with SMTP id u17so10467527pfn.7; Mon, 27 May 2019 19:19:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=ElrAVYgD/pSAQ+6wQeGjrI42nh6rZoHmZOAfKuzcT8A=; b=vIc21H9T5LGBgUwhAb/LkJd3XusoSLmb4Q14pPQ5a9BIlSGrc3P3Jjs+ShUFsvA7S1 x2VL371PJR10mD2sZhvpZZ7chIBmKgAFze604Ij1JHj9P4mcwK5Id0v2/a3I/tMg4Bza xtGCQ3NNVBxsBoC1XQ9GG92hrSa3mIoVKhZyU7eq6WRCT0xuUtTkWZY+g1ycIyFW6QhO gMrYlsY/xrlAIbN9E/QLVvU3eCJaF+RAQmGIpH3fsdCr5GnImqUH89lMcEX5OxcrzoWi qw5iKfVVnbuZru0kuNoTLm8DsMm3F/eyPXVxU4VN8nCKr+kKFrqtEgFkXZ0Ee/OIHxeo vUzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=ElrAVYgD/pSAQ+6wQeGjrI42nh6rZoHmZOAfKuzcT8A=; b=WzIKQak6jimLDRESfnkF5kLQjoqvU7OrbiQhVWeuRDiDkkYeTMFnh07VB8hliUC0BU khhKljDXBq0st4U8xjFaH28yV6p6TFTY7Q284OnwguS4BNT5zpsFJJ4lijHyJW+HHRKA UTEEDr8qumBHbGLtG5THjG7kXXsLulMe1ZYBQG9hAJqfelbClU0pZIRAUCxUaQYSdw4m MWGZFA53p8uyeGFhJCqnpHoJeOLavE55saTzB1POHARQY/rB3Rhz/WX/C8QwACn4Szyl NqiAaCZ+54LP0i1RjFkVKQ293kOp03pigXnEISeIMEQ0GEUkNiM8hVUozV7sOcz6am0+ iGdg== X-Gm-Message-State: APjAAAVdWsQ+B+Ikxp/F1NytFIiGfjx8PWxc91kSKr0+/J8ytGL2afhT Z3kcZweP+9MrNZVLFpkGl0s= X-Received: by 2002:a17:90a:8586:: with SMTP id m6mr2256305pjn.129.1559009954183; Mon, 27 May 2019 19:19:14 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id b4sm12463484pfd.120.2019.05.27.19.19.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 27 May 2019 19:19:13 -0700 (PDT) Date: Tue, 28 May 2019 10:18:51 +0800 From: Gen Zhang To: emilio@elopez.com.ar, mturquette@baylibre.com, sboyd@kernel.org, maxime.ripard@bootlin.com, wens@csie.org Cc: linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk-sunxi: fix a missing-check bug in sunxi_divs_clk_setup() Message-ID: <20190528021851.GA14526@zhanggen-UX430UQ> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In sunxi_divs_clk_setup(), 'derived_name' is allocated by kstrndup(). It returns NULL when fails. 'derived_name' should be checked. Signed-off-by: Gen Zhang --- diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index f5b1c00..830bfb7 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -989,6 +989,8 @@ static struct clk ** __init sunxi_divs_clk_setup(struct device_node *node, if (endp) { derived_name = kstrndup(clk_name, endp - clk_name, GFP_KERNEL); + if (!derived_name) + return NULL; factors.name = derived_name; } else { factors.name = clk_name; ---