Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2584516ybm; Thu, 23 May 2019 20:48:59 -0700 (PDT) X-Google-Smtp-Source: APXvYqxLCByZLwYkFKs68qeCoUtyFtugE+E8fnQunreobB8JBL2EpaQMqZDAA2rF4CkFD5/QOtB6 X-Received: by 2002:a17:902:1621:: with SMTP id g30mr62153677plg.326.1558669738952; Thu, 23 May 2019 20:48:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558669738; cv=none; d=google.com; s=arc-20160816; b=cBK3z4BIwULBeusb2aRRAbivTaPHlHbmkph7ZsEfILgKxcP98++6XkNPgoFZqQ7ynF kHm5DcZqaPXVJzRmqiWFdDnbd3dvgoCreB2TGAv1iOK7wQX51kHtjd1S18obVW3A5rII d/NdvItiN6Vks1MutNpZuZPXgJi/8V1FVDU5fL4NE0+/ZDfMBFbGJwFfdiwCewISyk2W r2GOPp6pJ4lDSO+zC0WMHHeLZO5Fagm1QquFs/AuOLswGPmSeV8BSLZyUsGr0FvSWO7y FbiBEO3M7Hxlz2aeaF866NFiwge58HF9qQEU570+msH5Nc/w06Lu3sWVQ1adfQ5CTzhQ NRtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:content-description:mime-version:references :message-id:subject:cc:to:from:date:dkim-signature; bh=hauV9TUbw5u5o6lbfxr6yYOMnoD47dNbzCMdRzyXMW4=; b=hCKRe8o8fcQBPd+61Sf3faJUxTQ4+MlR4BuMLgQKhooJ0RV6ffdA3o41m4sHW/izJY d5KruyM2DwUa8QjvajvYmEjFJGb93m4e/oxvwMeGjcrSGJoJ1U9+wp/hfZ/AuFH3Ch8S /KwNvqrym7xmZHTF5bWaouxz55aY2Dap1B/piWew9aGeg/xjfdYqt+IplhztPyspWzAb 05zfUz2f7PF8Ix4C4tO6eXrXGORqp9bNR9JWdHP0EyKVujoP6oM9lLwfegi8j3aG+HHY NdFZySlpZuCRbRXi7iy39u81iVhKeW/phcne/QAMMoQ1CsAMJmanV2Ret7tfu6kWZ1M7 J2ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=JjpqvWwK; 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 d2si2353521pgv.315.2019.05.23.20.48.38; Thu, 23 May 2019 20:48:58 -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=JjpqvWwK; 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 S2388335AbfEXDpf (ORCPT + 99 others); Thu, 23 May 2019 23:45:35 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42888 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387454AbfEXDpe (ORCPT ); Thu, 23 May 2019 23:45:34 -0400 Received: by mail-pl1-f193.google.com with SMTP id go2so3577002plb.9 for ; Thu, 23 May 2019 20:45:33 -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:references:mime-version :content-description:content-disposition:in-reply-to:user-agent; bh=hauV9TUbw5u5o6lbfxr6yYOMnoD47dNbzCMdRzyXMW4=; b=JjpqvWwKj85+WeGdh2yxx14jPuEreKgqk/18fF726jZmg/FKSvbtfU2gB4jbgnJOCP CQL3GZyd1dE/toTILUG8zIMO4NqOiX7R1kdZjUf8WZ67KgoQkiJ+QNIBRjAZ+6cUtqwe +htLSyFAyk/v+eltnGIP7OIPoZhQdp9SDRUmlHIUAI/0QaFiOrJDsgGPoT1Jpl1W65H0 LIIgKfvtPPSTkACn1rVT8ss+UxDYXKUzotcNdUr4RSBThTxn+KpYRd/aBu+ZT5W0aM3T vsIvvrC9i0LHr7EMsQOnsSNh6vpRZTfcfLFKeSjk/nDfaVTqHnL3YmvOVsNVSJN1JKjC 1OdA== 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:references :mime-version:content-description:content-disposition:in-reply-to :user-agent; bh=hauV9TUbw5u5o6lbfxr6yYOMnoD47dNbzCMdRzyXMW4=; b=flh6XvVQUWm8H/XIqKs5S2ZPsARHzl0EmuV4A7nz6zKvOS2wzfGAI7XKC4hJ69uciS oAn8I+/oLG0sNREZy3ZApBq+KQ/4C+/gcB7K1J1wFBeW0KHVvgYSIuxS0BRhjiMTLSq1 aEPPx9UJcnDsQpiL+AHCVr+bEYcBqoEgHx/FJlGM9bba6u813jWi5EIEsdvf5xLeog+I rVVuB8U78Eq3zCIBljrnDpXQh7EkbO/4+1ddf+XLZ1TQmxi6tReSTUAo9VvywLiMQ+E/ 2XkklzpSJaPp9RtpX3/SGCoEfSJmLULOgrZErJH0yDhCqTXSY1bvddMCmMSx32sHotib wzqg== X-Gm-Message-State: APjAAAXjxvcTeUgagpojv6YdxwDO1HgN5+qg1O5Djqc0W0kySwvXnNMw 9EqLj06cT3kAIwebsHiNbW0yvTCfrYsxNQ== X-Received: by 2002:a17:902:24b:: with SMTP id 69mr13257237plc.255.1558669533485; Thu, 23 May 2019 20:45:33 -0700 (PDT) Received: from zhanggen-UX430UQ ([66.42.35.75]) by smtp.gmail.com with ESMTPSA id n12sm770911pgq.54.2019.05.23.20.45.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 May 2019 20:45:33 -0700 (PDT) Date: Fri, 24 May 2019 11:45:17 +0800 From: Gen Zhang To: Andrew Morton Cc: rppt@linux.ibm.com, david.engraf@sysgo.com, steven.price@arm.com, osandov@fb.com, luc.vanoostenryck@gmail.com, axboe@kernel.dk, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] initramfs: Fix =?utf-8?Q?a_?= =?utf-8?Q?missing-chek_bug_in_dir=5Fadd=28=29teven=2Eprice=40arm=2Ecom?= =?utf-8?B?44CB?= Message-ID: <20190524034517.GA6821@zhanggen-UX430UQ> References: <20190524033045.GA6628@zhanggen-UX430UQ> <20190523203523.8f638f378b54df0ef7a18f9d@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Description: =?utf-8?B?YXZpZC5lbmdyYWZAc3lzZ28uY29t44CB?= Content-Disposition: inline In-Reply-To: <20190523203523.8f638f378b54df0ef7a18f9d@linux-foundation.org> 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 On Thu, May 23, 2019 at 08:35:23PM -0700, Andrew Morton wrote: > On Fri, 24 May 2019 11:30:45 +0800 Gen Zhang wrote: > > > In dir_add() and do_name(), de->name and vcollected are allocated by > > kstrdup(). And de->name and vcollected are dereferenced in the following > > codes. However, memory allocation functions such as kstrdup() may fail. > > Dereferencing this null pointer may cause the kernel go wrong. Thus we > > should check these two kstrdup() operations. > > Further, if kstrdup() returns NULL, we should free de in dir_add(). > > We generally assume that memory allocations within __init code cannot > fail. If one does fail, something quite horrid has happened. The > resulting oops will provide the same information as the proposed panic() > anyway. Thanks for your reply, Andrew. You mean that it is not necessary to check memory allcoation in __init, right? Thanks Gen