From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.9 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C5DBC65BAE for ; Thu, 13 Dec 2018 11:14:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3B1CA21479 for ; Thu, 13 Dec 2018 11:14:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3B1CA21479 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=osadl.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728735AbeLMLOE (ORCPT ); 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> 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