Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp1365560pxb; Fri, 21 Jan 2022 16:38:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJy4oyCmXLFhXiJ/qxSu2sJ89md5Pkl3lRUHqOCqU7OsPpoxPOUrnd7eneeD8fEylDgAuX5h X-Received: by 2002:a17:902:8492:b0:149:7c77:7254 with SMTP id c18-20020a170902849200b001497c777254mr5841610plo.19.1642811884082; Fri, 21 Jan 2022 16:38:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642811884; cv=none; d=google.com; s=arc-20160816; b=ududHqqsyyfuYeJbQh1Pz7YNJf8AkaPDBZszC+PkCBQVKCydYWPlkfdBiKstBd/LUI ELBUV07CSceCkp9Gxi5hklxVb5KOd5LJ74B36DwVvvMIVkt3aOQkLRSzTCOsjwggye1x TDku602aan9v6HKgxWWVHTpPHQqnnsxiAYpHd0zl+ltabtigu8y0t+U4gH//M+hUdJ1x uhCOMQ1fZ3YKeoyh7+jZC/YC9KdkFMMJC4QjODQuaXVkfoVqligfyrIuWOVtYblK1anl jNA1kYAChdP/Z3ViIE0i8WhVxLBrjB5uSxkqrQxKlYDSZS7kCQ4zGucYYKa31i0FKYgC FJbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=jnlvYy+Uw6xB9scz7VF8NmGUbHHbxz8VQEf0H2bQEP0=; b=GzVOZVh44GKb1fe8FRqZNa8rwctW37fb3+Yqozei5HK/XOFwcBMIPwGTieOZtwzw2I BHLm0IshdCiwCfG2VMT/7YQ2HG8gZvWCop2YeIkH50ZYPsFz47aGATTHvBPSQQZ+LABy m9SP5xsMNrokn4+SWyo0xHRyXIuHH1RWATnjR6QsT+wl2m5TGAd5pmXWKQ5xRaug4JHx GUVH1JM632G/A7uKmD5hYPKNFIVkf6poEa+sToARgljbG2S7NBRZfriwmLWV2SBEgRqL 00mYpiRIgGSkPpJ8vlAuDCW2qQWzHt/6i0EBNsHMgcpxWEgmTWiEQxOuynhX/wmHBWof dYNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fL0RBll7; 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 a70si3591288pge.99.2022.01.21.16.37.52; Fri, 21 Jan 2022 16:38:04 -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=fL0RBll7; 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 S1379004AbiAUHb4 (ORCPT + 99 others); Fri, 21 Jan 2022 02:31:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378998AbiAUHbw (ORCPT ); Fri, 21 Jan 2022 02:31: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 4DF9FC061574 for ; Thu, 20 Jan 2022 23:31:52 -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 5BB95617AC for ; Fri, 21 Jan 2022 07:31:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 23551C340E1; Fri, 21 Jan 2022 07:31:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1642750310; bh=vtR/YwAdNWGjtH8j5ag/QHqghKk8vLOzrc+UOKUndDQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=fL0RBll75ZLtYh/LuinuDXJcMo9mfP6JwfIlyj9G3J5hXhsw1evmbfTU+IrxguXEm tJ0e4Ol38j9BXIQTlPcYC0MP7DJWQ+d/LK+hQMIwPjMOFRP1o84PbzWdCjxzd0ZGLJ 1FAQQro343RbQoJrGFzD5TOYXwo/g4zZQRBeU7JQ= Date: Fri, 21 Jan 2022 08:31:47 +0100 From: Greg KH To: Jiasheng Jiang Cc: jirislaby@kernel.org, jcmvbkbc@gmail.com, dsterba@suse.com, johan@kernel.org, dankamongmen@gmail.com, penguin-kernel@i-love.sakura.ne.jp, igormtorrente@gmail.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH] tty: vt: Check for NULL pointer after calling kzalloc Message-ID: References: <20220121065320.2283544-1-jiasheng@iscas.ac.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220121065320.2283544-1-jiasheng@iscas.ac.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jan 21, 2022 at 02:53:20PM +0800, Jiasheng Jiang wrote: > As the potential failure of the allocation, the kzalloc() will return > NULL pointer. > Therefore, it should be better to check it in order to avoid the > dereference of the NULL pointer. > When it fails, we should free all the allocated memory and return error > number. > To make the code more clear, I use the 'err_free', like how > vc_allocate() deals with the allocation failure. > > Fixes: a5f4f52e8211 ("vt: use kzalloc() instead of the bootmem allocator") > Signed-off-by: Jiasheng Jiang > --- > drivers/tty/vt/vt.c | 19 +++++++++++++++++++ > 1 file changed, 19 insertions(+) Please note that your patches are being ignored by my email systems (I saw this because Jiri responded to it.) I recommend at this point in time that all other kernel subsystem maintainers also ignore them until you get some more experience and provide changes that work correctly and are actually tested. good luck, greg k-h