Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3721912pxb; Mon, 24 Jan 2022 16:19:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJynQAyQ2gDBjn83731hKk5VHYlpoTQyplG9A+KXxILJ9x6XFCUGGPpBJD1H+jDWvIeLMemB X-Received: by 2002:a17:903:4101:b0:14a:cae5:48a with SMTP id r1-20020a170903410100b0014acae5048amr16599264pld.25.1643069954428; Mon, 24 Jan 2022 16:19:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069954; cv=none; d=google.com; s=arc-20160816; b=hqGx2tooJ8v2mIgmbIdiVU8n2F0M9/7wu5EYGX82rAp/zMGtsc6VC/tD7i5zoCsKkp 5XMnkBe7ggye446+IPk+vMkFofk3VLPWK0yEt8bI6zwY2yjZZ0DmlSk6XY0lf0/Gunx6 hYqFB+HTMHP/x8mK/1Kj9Rw/hnFSbg2YQDwXWLneswjFBAAEC1UjyEWzX11A9ZT9oRIh CPfSZkKdXtiv54PQq93E8+J8fel+vSA3pw6Kghoth5v1Q65rolRzQJnksYE3UAglwCqO WWSs/wgdq/msbveYk8CbFon4EN3nSQ5rBFCxizfUqfXFMgnKzMtMGqWo84qsW0O4DHBp SjCg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xD2zaO40dJpwFHAi7ztJ0Mt5y+LT1BoIccOQTCbdH50=; b=Dwtib0FoLYNi+/sNbRX1a/WCtrWMqtLH+7QD5UGC6k6J3Az2UKHFes6H6dbPmpg90s TgUzgXCc3onkbxxyCjAYpgy1EYSumm/5FRbHgq035HoWlQAkm6WZRqFbyIkCxV1YXv9c vbIzxKv96l2m3HuRgaufkWWZEsNJINoagkhH+Amaxocgsd2wQbUPh6b9GegqdvHoGcYV tYqN/Ev+XGpPQMV9lRyX6+xQbDWHaw/FrarFyV83jqZ1ZJG279N2rKoem0bHfnF9CLQG MFiydwoH5/RT9fVAOyemWOiJx5shWxmZRK9ZKZpa3VQxoGnKmoWWi0FpJTrlnMZf4wqU Aa5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hU0UN28U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si13277107pgc.510.2022.01.24.16.19.02; Mon, 24 Jan 2022 16:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=hU0UN28U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2373191AbiAYANS (ORCPT + 99 others); Mon, 24 Jan 2022 19:13:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1850382AbiAXX3w (ORCPT ); Mon, 24 Jan 2022 18:29:52 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6BD16C0A8880; Mon, 24 Jan 2022 13:34:32 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0D639614CB; Mon, 24 Jan 2022 21:34:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E7DA0C340E4; Mon, 24 Jan 2022 21:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643060071; bh=7DerX0b8DALAtu6wevcGsJHv/dcYVQh4/h5h4IeCgWI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hU0UN28UAz0bk/y0EyLR65JG//bYGiiHiev/4UbrxCoOlPTa7KJE0dPx29G/AVNgi LlIu/Cb9iUNVrfjE4BKgSqrvqDZ0UKf16qgBLYmql+kAcWLkA9Kwn393kpC9pDhedP UqqWbWGQCjkAypm5fc+u6LlRVjL3IrHCRKhhaLNM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Xiaoke Wang , Steven Rostedt , Sasha Levin Subject: [PATCH 5.16 0828/1039] tracing/probes: check the return value of kstrndup() for pbuf Date: Mon, 24 Jan 2022 19:43:37 +0100 Message-Id: <20220124184153.119249971@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Xiaoke Wang [ Upstream commit 1c1857d400355e96f0fe8b32adc6fa7594d03b52 ] kstrndup() is a memory allocation-related function, it returns NULL when some internal memory errors happen. It is better to check the return value of it so to catch the memory error in time. Link: https://lkml.kernel.org/r/tencent_4D6E270731456EB88712ED7F13883C334906@qq.com Acked-by: Masami Hiramatsu Fixes: a42e3c4de964 ("tracing/probe: Add immediate string parameter support") Signed-off-by: Xiaoke Wang Signed-off-by: Steven Rostedt Signed-off-by: Sasha Levin --- kernel/trace/trace_probe.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 3ed2a3f372972..bb4605b60de79 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -356,6 +356,8 @@ static int __parse_imm_string(char *str, char **pbuf, int offs) return -EINVAL; } *pbuf = kstrndup(str, len - 1, GFP_KERNEL); + if (!*pbuf) + return -ENOMEM; return 0; } -- 2.34.1