Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1739263ybj; Fri, 20 Sep 2019 15:53:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPnjRM79CFGNE/ArOG2ZfdwRtRDVzLU7Bbsm4qzfAg2F+514pzYNwPex+h2rjMG66Upn78 X-Received: by 2002:a50:d949:: with SMTP id u9mr24522411edj.142.1569019999977; Fri, 20 Sep 2019 15:53:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569019999; cv=none; d=google.com; s=arc-20160816; b=q+iIaQ2cdFAoCYXnQVWPpXv7kAcEYn09RXZG5qAjRGRQJuiq2FVAdbfJ6JxnL7kdGD +EWH2FCKtPPTDLaWeAoxvV0S+l3R/yTmzUp0OCXzMOBDZvRw5Q7ZDbYfx2XKxosbOBIH CT/xHAlgNMo5sH7JPZTSjebU9pwf23fZcQdnrTqH0Pcq2dsnDlmb+rEqSlsRKxJ+imhc T79CSpRV3E9RL8HR0eGLYsH9bksqlCduBZV7pTWrJQBdF1Zveqmu62PvYRtUqxtYrkUK qJX/SY9KdYL1uE0M7EEcKPhzN6y9/z7nfjE3uM0KIduw2RrLWGDnxCyeNFxLSUyl0H5J iUDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=/SQcBcrmbSianj+iBjogwGaJzNRPCgkY0/U3PuOu1s4=; b=B5xEVZm4PjYKRnJ5CoV8Y+GtiBFCikatk4/Qjf2iUXDwAV8013fDgbPJXVpQbEHpV+ xV88eMUCZIWoLzQzD+HLvMkWTQ3ZUDB7NMnM/zZVp4BT+1VeLws8QnNeT4LMvAss2A/b u7SEeNIBGnpqV0Qf+P2co3QRJgj9gyEMbZSuIVVSym9Dvi61CvqbHyTxZG6i7HBlSGq4 Ot/AWY1Ueu5VDsg4L+IgHIN8oAUn7i1aqnJZoh0mw2NXgGOIcNCHnpd7H5tPekyE5lbL X2yfd4C4xLcqsVNX0BTZ4+p2P+oX6WnECYp4FWZ15cYkUjgBcxmxiBKDG8XyoOeDK9jh Cpyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pobox.com header.s=sasl header.b=OdjC06zX; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=bEOK5oau; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si2364154ede.255.2019.09.20.15.52.56; Fri, 20 Sep 2019 15:53:19 -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=@pobox.com header.s=sasl header.b=OdjC06zX; dkim=temperror (no key for signature) header.i=@fluxnic.net header.s=2016-12.pbsmtp header.b=bEOK5oau; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2405520AbfITC4V (ORCPT + 99 others); Thu, 19 Sep 2019 22:56:21 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:53730 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404240AbfITC4U (ORCPT ); Thu, 19 Sep 2019 22:56:20 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 66E8D27046; Thu, 19 Sep 2019 22:56:18 -0400 (EDT) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=date:from:to :cc:subject:in-reply-to:message-id:references:mime-version :content-type; s=sasl; bh=DxwA3Xb/j2BmQm76HYP5HmvpMK0=; b=OdjC06 zXUq8YTULHORUItoAvRfnXd08ov9T5VOAE7PUdURZvaXDFIBu2tDUneLwCI+u7fT 8mXT3pACfe7gXr29NpHrQYUEgX2U0XuXnEASOXyJEKp9gFxnprvG7b5Ppg5d6AQJ g/BbnQeuxyLK697twtLUq9bztkvA8FT9mEJtY= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id 5C03527044; Thu, 19 Sep 2019 22:56:18 -0400 (EDT) (envelope-from nico@fluxnic.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed; d=fluxnic.net; h=date:from:to:cc:subject:in-reply-to:message-id:references:mime-version:content-type; s=2016-12.pbsmtp; bh=KxVWMOQwuPubePImZVl5t1gqR2PwuYXiHV8sMvllCO4=; b=bEOK5oauHGt+2Vquj2cCGyyusTHwIBz7dSIQCFCFQG5bJPfYxBM4DfrV9G6Wp5h1lDlmtrWow6/NGlKOO4VamWy5uu8+7gLlg9l46wQ/aJROI+9TPnUhwtdcw1TzNR8Jjz9N6VgstxIPcIDslC88UAhXyJrHjwt7haI6LUHU4zU= Received: from yoda.home (unknown [24.203.50.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp2.pobox.com (Postfix) with ESMTPSA id AE87527043; Thu, 19 Sep 2019 22:56:16 -0400 (EDT) (envelope-from nico@fluxnic.net) Received: from xanadu.home (xanadu.home [192.168.2.2]) by yoda.home (Postfix) with ESMTPSA id DB46D2DA01D7; Thu, 19 Sep 2019 22:56:15 -0400 (EDT) Date: Thu, 19 Sep 2019 22:56:15 -0400 (EDT) From: Nicolas Pitre To: Greg KH cc: Xiaoming Ni , penberg@cs.helsinki.fi, jslaby@suse.com, textshell@uchuujin.de, sam@ravnborg.org, daniel.vetter@ffwll.ch, mpatocka@redhat.com, ghalat@redhat.com, linux-kernel@vger.kernel.org, yangyingliang@huawei.com, yuehaibing@huawei.com, zengweilin@huawei.com Subject: Re: [PATCH] tty:vt: Add check the return value of kzalloc to avoid oops In-Reply-To: <20190919092933.GA2684163@kroah.com> Message-ID: References: <1568884695-56789-1-git-send-email-nixiaoming@huawei.com> <20190919092933.GA2684163@kroah.com> User-Agent: Alpine 2.21 (LFD 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Pobox-Relay-ID: 36F541B0-DB52-11E9-A06F-D1361DBA3BAF-78420484!pb-smtp2.pobox.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 19 Sep 2019, Greg KH wrote: > On Thu, Sep 19, 2019 at 05:18:15PM +0800, Xiaoming Ni wrote: > > Using kzalloc() to allocate memory in function con_init(), but not > > checking the return value, there is a risk of null pointer references > > oops. > > > > Signed-off-by: Xiaoming Ni > > We keep having this be "reported" :( Something probably needs to be "communicated" about that. > > vc_cons[currcons].d = vc = kzalloc(sizeof(struct vc_data), GFP_NOWAIT); > > + if (unlikely(!vc)) { > > + pr_warn("%s:failed to allocate memory for the %u vc\n", > > + __func__, currcons); > > + break; > > + } > > At init, this really can not happen. Have you see it ever happen? This is maybe too subtle a fact. The "communication" could be done with some GFP_WONTFAIL flag, and have the allocator simply pannic() if it ever fails. Nicolas