Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2802057yba; Mon, 15 Apr 2019 21:03:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqw3PRiVZbgaXjkXA9PzdKet9cyB8uTLYdE0H1oNq14FdGLGzSwM4ds6X2hsBkm0nTySAT9P X-Received: by 2002:a63:6941:: with SMTP id e62mr70969665pgc.99.1555387418917; Mon, 15 Apr 2019 21:03:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555387418; cv=none; d=google.com; s=arc-20160816; b=dAIvjbh3j/XubPS+7oo0XKMA2rxZkdU3hT8n0mnhC1zECE/kTVUZjF4I1BMXCxRG/o h2ufsT16GYbhN5VkkO4soPkyNBwepj81QqLIC5VNzrd78CJA+Xgq8k8CJ8k6f3Q+lxdp vUaIUfrEBUWMp2gqKgolRSyrgHqK7WE9A4w8cj2PY2H5S0ZPkTcPmZlRB7s6K1hkf4YR QhgGpiFuFX497In1blEmov0jkA6TQVLpAxFxsrict1YeRm05XMqtH1wcFibtPMs0RL8s rAUs0/AsY1HxzLx1g6aXXP9qosWIoKXxi9zWl8wI5+cMhC04ItG5wec4JHefbBQda+aH TbDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=PQ58ZASV/QbLOXbOVoVz+zTOkiuW4zgCL0vnWa76CvY=; b=jJvY+c4DauIcjzhgZKToPn4/Jyzwv/Q5YWVi4KgrYpEPiykrbSNxsP/GgEnkjFHib4 rruef7wYkk7LGGZn40+HHH7sg2RTc3noKhhbALDNqErUrWKEO23JfaZzLGbzV8suw1e2 tD0bziGKeYEY+3/4UjSvxkZDQd54hoxM/NvuNLmuDeXqdFkQ1kn8WnpumZ+IUKJE3+tX 7emR4H15Q3fy2pUCTgm8n5DXyuv4PBmZiNiQ2942ETzKyrbFzhpy1yczFOxpVd5Rw5Mc +sM+bKXPu+eIkQUWrGUQ26dL9Mo9NcTE9+IHWK4r3RXzEo0kCDq6odsZjmINBdAq0Vde DerA== ARC-Authentication-Results: i=1; mx.google.com; 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 l62si34396360pfc.65.2019.04.15.21.03.22; Mon, 15 Apr 2019 21:03:38 -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; 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 S1725850AbfDPECm (ORCPT + 99 others); Tue, 16 Apr 2019 00:02:42 -0400 Received: from www.osadl.org ([62.245.132.105]:49136 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725648AbfDPECm (ORCPT ); Tue, 16 Apr 2019 00:02:42 -0400 Received: from debian01.hofrr.at (178.115.242.59.static.drei.at [178.115.242.59]) by www.osadl.org (8.13.8/8.13.8/OSADL-2007092901) with ESMTP id x3G427M9032015; Tue, 16 Apr 2019 06:02:07 +0200 From: Nicholas Mc Guire To: Jason Cooper Cc: Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Russell King , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH V2] ARM: mvebu: at least report the kzalloc failure Date: Tue, 16 Apr 2019 05:56:31 +0200 Message-Id: <1555386991-8855-1-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 X-Spam-Status: No, score=-4.2 required=6.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on www.osadl.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Although it is very unlikely that the allocation during init would fail any such failure should point to the original cause to allow easier understanding of the ensuing null-pointer dereference splat. Signed-off-by: Nicholas Mc Guire --- Problem located with experimental coccinelle script V2: Russell King pointed out that the use of WARN_ON() would result in a stack trace followed by the oops due to dereferencing of the NULL pointer and so make it even less likely that users would uncover the actual cause - so drop the WARN_ON() and use a short pr_err() message that points to the oops cause directly. Note that this will trigger a checkpatch WARNING "WARNING: Possible unnecessary 'out of memory' message" but comparing the oops with an without the one-line pr_err I would argue that it makes sense to include it: [ 8061.514840] shared page allocation failure in hello_init() [ 8113.563239] BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 [ 8113.563250] #PF error: [WRITE] [ 8113.563255] PGD 8000000129993067 P4D 8000000129993067 PUD 129992067 PMD 0 [ 8113.563267] Oops: 0002 [#1] SMP PTI [ 8113.563276] CPU: 2 PID: 2656 Comm: bash Tainted: G W O 5.0.0-rc3livepatchtest-next-20190123+ #4 [ 8113.563280] Hardware name: Quanta TWH/TWH, BIOS QU221 10/14/2011 [ 8113.563292] RIP: 0010:foo_store+0x3a/0x90 [hello_chardev] ... Patch was compile-tested: mvebu_v7_defconfig (implies MACH_MVEBU_ANY=y) (with some unrelated sparse warnings about missing syscalls) Patch is against 5.1-rc4 (localversion-next is 20190415) arch/arm/mach-mvebu/board-v7.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c index 0b10acd..df84cb6 100644 --- a/arch/arm/mach-mvebu/board-v7.c +++ b/arch/arm/mach-mvebu/board-v7.c @@ -128,6 +128,9 @@ static void __init i2c_quirk(void) struct property *new_compat; new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL); + if (!new_compat) + pr_err("new_compat allocation failure in %s()\n", + __func__); new_compat->name = kstrdup("compatible", GFP_KERNEL); new_compat->length = sizeof("marvell,mv78230-a0-i2c"); -- 2.1.4