Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp714309imu; Thu, 13 Dec 2018 03:15:10 -0800 (PST) X-Google-Smtp-Source: AFSGD/XM4gQuBb1LZ9/foPOC5d63K7cIyZZtXloKc1oP9G2b5RbvDW3n5cbCLoiJXLndpzgfexsi X-Received: by 2002:a17:902:b282:: with SMTP id u2mr23647537plr.89.1544699710594; Thu, 13 Dec 2018 03:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544699710; cv=none; d=google.com; s=arc-20160816; b=ZhUf33zsxihjSNTS7vM8e9jSoLlbTIS+8nwJFwxpGdBelAPk1wk0aWCnauuEKCTpCz nXsxVpDBRj4xzR3R0IEZC3NTOdBG1MJ7cfyyIWfRIq1eyPSp8S1YcHXY8EX6WWKuCvNF KF5oJWOqENOvZK7wDeNYIhRZrSJzVOlpx56rFI12ElVx9jKyWxeXMbFC15E7LQaU/Qqe nhOIgF4qUlS13tu2AIIJRRsgCKLzAWCdKFsGIR9brSP9Agdybk/okz00788JI7KcxbhW Ihs6ohRpZ19QC3orOC8Jdui+wguAvjZ0dNhqQfieje9h/W8shqPI6ObvKQ6dPmuhleWU pp5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=UtjMwzL9COAk2vNFlR98yJ2Q69oOqtF7/THJ3Jcu6NY=; b=NoZb+D/duWgzPidnYtkqFgM9sThZmdAdKOHfxDtgLXPjdkfgSg9HdqE3TGkghrXeRq Vfn6MuINgRGjJ0osJ2EAXz8mNfG0I0Pxs9IBHiv3jCPzcenQ9eCmQ3JbKvPTYjO+XMkq N6dnSSUlTdeqU0j9Gf1Ty87yVFXjuGkpTu7r2cM3aekyzpGV2HneNPwcoFUn0uOjVA/n jMwmHBVqSrAnucz1ujRmu49725BxpbZB6/IgeGh4tt7XXIF4vgY+6vgaD/sddCvXmrTG KxG/NwD2MZHlmMwB1GiKAml/hJRVuNeJnQyy6mu0b9cVy6BB8yAhZEbAOm4w/SuPJRaC DEhg== 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 d2si1400499plh.426.2018.12.13.03.14.54; Thu, 13 Dec 2018 03:15:10 -0800 (PST) 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 S1728731AbeLMLOE (ORCPT + 99 others); Thu, 13 Dec 2018 06:14:04 -0500 Received: from www.osadl.org ([62.245.132.105]:51121 "EHLO www.osadl.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727590AbeLMLOD (ORCPT ); Thu, 13 Dec 2018 06:14:03 -0500 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 wBDBD6ZG021460; Thu, 13 Dec 2018 12:13:15 +0100 From: Nicholas Mc Guire To: Josh Poimboeuf Cc: Jessica Yu , Jiri Kosina , Miroslav Benes , Petr Mladek , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Nicholas Mc Guire Subject: [PATCH 2/2] livepatch: handle kzalloc failure Date: Thu, 13 Dec 2018 12:09:50 +0100 Message-Id: <1544699390-15673-2-git-send-email-hofrat@osadl.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1544699390-15673-1-git-send-email-hofrat@osadl.org> References: <1544699390-15673-1-git-send-email-hofrat@osadl.org> X-Spam-Status: No, score=-1.9 required=6.0 tests=BAYES_00,DATE_IN_FUTURE_96_Q, 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 kzalloc() return should be checked. On dummy_alloc() failing in kzalloc() NULL should be returned. Signed-off-by: Nicholas Mc Guire --- Problem was located with an experimental coccinelle script Patch was compile tested with: x86_64_defconfig + FTRACE=y FUNCTION_TRACER=y, EXPERT=y, LATENCYTOP=y, SAMPLES=y, SAMPLE_LIVEPATCH=y (with a number of unrelated sparse warnings on symbols not being static) Patch is against 4.20-rc6 (localversion-next is next-20181213) samples/livepatch/livepatch-shadow-mod.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/livepatch/livepatch-shadow-mod.c b/samples/livepatch/livepatch-shadow-mod.c index 4c54b25..57d5cde 100644 --- a/samples/livepatch/livepatch-shadow-mod.c +++ b/samples/livepatch/livepatch-shadow-mod.c @@ -118,6 +118,8 @@ noinline struct dummy *dummy_alloc(void) /* Oops, forgot to save leak! */ leak = kzalloc(sizeof(int), GFP_KERNEL); + if (!leak) + return NULL; pr_info("%s: dummy @ %p, expires @ %lx\n", __func__, d, d->jiffies_expire); -- 2.1.4