From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 C731C18871F for ; Mon, 29 Jun 2026 23:51:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782777108; cv=none; b=JuKcbjSyIEvKHhnhnzlGaLNsgkCAJ0VwKXRa62wEW4yaDaSJ/ACdb1X2blSrgRouRUF8PMADmP9eYQHs6HUcmM564TzB8xFk9BCahfcwTaMbAs0lS6pG398eNn8tQk/sXR2glvU6PEL7YStYrpIV6EDpiWpfJzUvPmUsOZ/phqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782777108; c=relaxed/simple; bh=ufBqfvNZ3Mgfwr+kIhGfuJ/FSe1lA87drGTDHjl0KhA=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=rWqJ07bZOlpspLwM6QySoewBiqFTK9K1yz8kML/arGHcEPjdD04nvnZ2KLH95NhHne/wv/1SJ/m7e3goNJy7tToPugIgErGqwuODXeiZe5iEmq6qmLC8NaOmXCwxUh0oRObtYwVe966c8SU0VEwAc9ZzPLz23ypLI6clgXAGIgI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=Yrra0xe7; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="Yrra0xe7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 296521F000E9; Mon, 29 Jun 2026 23:51:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1782777107; bh=wdasxMd26oqugD7eLY13AZ+xPMdkCRGnLn1AM3E7D5E=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=Yrra0xe7a6moBzKEPtRNX/W5FfvpLXXuiuFRQ840abpHCLYjOOOfeyX8nFEzAzt8t 8GNL/UV+8rGYmM3ZoWCUtzjwffsV7kLq8O1HK0zZezqobOg3IWuNqWv1CMRNHU1FHb 5LMCDYPGT7yKXSZOQ23k/4/P9KQMuzubK1W1LGR0= Date: Mon, 29 Jun 2026 16:51:46 -0700 From: Andrew Morton To: Martin Weiss Cc: linux-kernel@vger.kernel.org, Martin Weiss , Jason Baron , Jim Cromie Subject: Re: [PATCH 1/4] lib/dynamic_debug: add NULL check after kstrdup Message-Id: <20260629165146.f8cce11cdd13682d482c0319@linux-foundation.org> In-Reply-To: <20260629093056.591498-1-Martin.weiss2410@gmail.com> References: <20260629093056.591498-1-Martin.weiss2410@gmail.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) 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=US-ASCII Content-Transfer-Encoding: 7bit On Mon, 29 Jun 2026 16:30:51 +0700 Martin Weiss wrote: > kstrdup(saved_command_line, GFP_KERNEL) may return NULL under memory > pressure. Add a check to avoid NULL pointer dereference during boot-time > dynamic debug parameter parsing. > Thanks. > --- a/lib/dynamic_debug.c > +++ b/lib/dynamic_debug.c > @@ -1479,6 +1479,8 @@ static int __init dynamic_debug_init(void) > * slightly noisy if verbose, but harmless. > */ > cmdline = kstrdup(saved_command_line, GFP_KERNEL); > + if (!cmdline) > + return 0; /* prevents a boot-time NULL deref */ > parse_args("dyndbg params", cmdline, NULL, > 0, 0, 0, NULL, &ddebug_dyndbg_boot_param_cb); > kfree(cmdline); We conventionally assume that memory allocations at __init time cannot fail. Sashiko explains why ;) https://sashiko.dev/#/patchset/20260629093056.591498-1-Martin.weiss2410@gmail.com