Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp1905917rwj; Sun, 18 Dec 2022 18:21:50 -0800 (PST) X-Google-Smtp-Source: AMrXdXs5s8SD5DqVX3JkudhXpLZ9Cb2v0cS71mJ9eQ+zD7wdm7Qwh63O/lyiV234Vx5F3VDHFSHv X-Received: by 2002:a17:90a:77c3:b0:210:a769:7ea1 with SMTP id e3-20020a17090a77c300b00210a7697ea1mr7362786pjs.47.1671416510412; Sun, 18 Dec 2022 18:21:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671416510; cv=none; d=google.com; s=arc-20160816; b=zwO9MOW9mZLlaEDB1kwk/aUvjF4Tg6CeoZEt4y4786Y8S9QTObzBHVfNQQ5vJqmRyo c+7deq5B3d6S2ucSmG+JxDCMLNsLmlt+aC1fckilGBWAHc7fEyA0JTmQ2LfNCTeANDue miIvWFvipZ2vxbwFeNBPSk/Q0Eu+fAUM+LtWwI55J9Mq1VpoUkENJ6jmx7c5ap3L8uMR a24OB8LIQ3gi0mTjcfJColZhsyXUL7fmdGHMelSiAlRwTUZDtb3fPMWTXdWG4x+dXFu8 YXY7o5cZX/PcIeM+5Cj7dP/S2xavdd1KdxyXV6BBERsNfwhQdq2xJqyPKTHp8t/slsmO jdxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=pE5GBQ+axLPs7S80kdVVtcIrNpykR22ycA9DkviEheQ=; b=vwbiTthTSX6QQkptNiZPRx7N5lCpc/tDsb03TJmKiwxw3PojQ0qdng6d3OPHQwCncp ZLMqJR/ja3rK3Q6GAlJeQakErojzk6cTDMBbUhH+YkmE5F8liTUF5sw+NiXbQ90FwBVS +/6KOHkYeMgmyXI8P7aAbqSEYpzbwsrAh4tvWHqd7X97S+oEZcMdaVPp2TBPdSN0dOBx bscvaYZZUuvGJxJZ/tGewbsV57v/DHxV82pAKqDIc33v3qkWiEvACrg8iVBjY8s2Q+P0 J17V12NPYyXS6esoE3BFgN6smHkKgJZThS3h5yfWMmhmG5yvZXsxFb4KxGNyl3txFpcR zPuA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b9-20020a63d809000000b004781e385185si8947771pgh.548.2022.12.18.18.21.36; Sun, 18 Dec 2022 18:21:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230481AbiLSCSe (ORCPT + 71 others); Sun, 18 Dec 2022 21:18:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbiLSCSa (ORCPT ); Sun, 18 Dec 2022 21:18:30 -0500 Received: from mail.nfschina.com (mail.nfschina.com [124.16.136.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6BC47636B for ; Sun, 18 Dec 2022 18:18:29 -0800 (PST) Received: from localhost (unknown [127.0.0.1]) by mail.nfschina.com (Postfix) with ESMTP id B3FFF1E80D6D; Mon, 19 Dec 2022 10:13:31 +0800 (CST) X-Virus-Scanned: amavisd-new at test.com Received: from mail.nfschina.com ([127.0.0.1]) by localhost (mail.nfschina.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id agkulhGKmcTu; Mon, 19 Dec 2022 10:13:29 +0800 (CST) Received: from localhost.localdomain (unknown [219.141.250.2]) (Authenticated sender: zeming@nfschina.com) by mail.nfschina.com (Postfix) with ESMTPA id ED2C01E80D32; Mon, 19 Dec 2022 10:13:28 +0800 (CST) From: Li zeming To: mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, gregkh@linuxfoundation.org Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Li zeming Subject: [PATCH] boot: simple_alloc: check after increasing memory allocation Date: Mon, 19 Dec 2022 10:18:16 +0800 Message-Id: <20221219021816.3012-1-zeming@nfschina.com> X-Mailer: git-send-email 2.18.2 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pointer new adds judgment and should help with program robustness. Signed-off-by: Li zeming --- arch/powerpc/boot/simple_alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/boot/simple_alloc.c b/arch/powerpc/boot/simple_alloc.c index 267d6524caac..db9aaa5face3 100644 --- a/arch/powerpc/boot/simple_alloc.c +++ b/arch/powerpc/boot/simple_alloc.c @@ -112,7 +112,9 @@ static void *simple_realloc(void *ptr, unsigned long size) return ptr; new = simple_malloc(size); - memcpy(new, ptr, p->size); + if (new) + memcpy(new, ptr, p->size); + simple_free(ptr); return new; } -- 2.18.2