From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0A9DD26E6F2 for ; Sun, 14 Dec 2025 10:23:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765707819; cv=none; b=syvGg2SV70kp+wk2eoj7mkBLdkqnM7EpwukwVq2hyS08XjXsktah87mB5SXv9z99xtBCNFYZBusy8cZ3iiIiFRSK+s9VwTEzIJXeH8HUjXjQnEEmj54vEGY90kyaXMr4wWSY6nXtbFgvu50cWppFcLorY6Ya4ubTWgc0z0uXOmg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765707819; c=relaxed/simple; bh=3PWna/PDCCCBfXf/r+4a3UV8147zd2APID0xkSc4aS0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=tSybsJDsV9SOczPVDvDlhTGa4AtVSrAEkIjtLuAYg0W544DphfM0C8YcmzGTNJ3JNLuQNfex6AilOQ9Dwgyup0yiaAF1G/9+ip70L6c+eos7Oe5MDytv235NvOTgB5S1fA4iYm+Hcv92UcvA0nMJ58sexZSUQxWzrTi3sa/QWIo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SvNZ88ym; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SvNZ88ym" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1765707815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=IJq4y3E9dGTIf4vZAfArLGlKhvp6jUao1b7lpRrCSXE=; b=SvNZ88ymRQ1jqjuxQUMhrJhIFrg+H68b6bmWqFqPFzlKFYNsek02CFraKSq0g92YypKSXn lMk6SjZLLuZnIdr6TUSlNiv6y1qbYMLwAcqmjBDzn3RX5Qx/PxTcKd/C3GAl98RhcJRBdL eX8ET9htUTfjsuPrw5SiPoy99wSbxfQ= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-92-QYNowiyPNtCbk28vVgKbkA-1; Sun, 14 Dec 2025 05:23:34 -0500 X-MC-Unique: QYNowiyPNtCbk28vVgKbkA-1 X-Mimecast-MFC-AGG-ID: QYNowiyPNtCbk28vVgKbkA_1765707813 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D5B4319560A5; Sun, 14 Dec 2025 10:23:32 +0000 (UTC) Received: from localhost (unknown [10.72.112.161]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 83DF930001A2; Sun, 14 Dec 2025 10:23:29 +0000 (UTC) Date: Sun, 14 Dec 2025 18:23:24 +0800 From: Baoquan He To: Qiang Ma Cc: akpm@linux-foundation.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kexec: Fix uninitialized struct kimage *image pointer Message-ID: References: <20251212071656.834079-1-maqianga@uniontech.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 On 12/12/25 at 06:53pm, Baoquan He wrote: > On 12/12/25 at 03:16pm, Qiang Ma wrote: > > The image is initialized to NULL. Then, after calling kimage_alloc_init, > > we can directly goto 'out' because at this time, the kimage_free will > > determine whether image is a NULL pointer. > > Rechecked the code flow, in kimage_alloc_init(), if anything wrong, the > allocated memory are all freed via out_free_control_pages and > out_free_image accordingly, any place missed? If no, I think the current > code is correctly handled. > > > > > Signed-off-by: Qiang Ma > > --- > > kernel/kexec.c | 4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > Acked-by: Baoquan He Cancle this ACK till above question is answered. > > > > > diff --git a/kernel/kexec.c b/kernel/kexec.c > > index 28008e3d462e..9bb1f2b6b268 100644 > > --- a/kernel/kexec.c > > +++ b/kernel/kexec.c > > @@ -95,6 +95,8 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, > > unsigned long i; > > int ret; > > > > + image = NULL; > > + > > /* > > * Because we write directly to the reserved memory region when loading > > * crash kernels we need a serialization here to prevent multiple crash > > @@ -129,7 +131,7 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments, > > > > ret = kimage_alloc_init(&image, entry, nr_segments, segments, flags); > > if (ret) > > - goto out_unlock; > > + goto out; > > > > if (flags & KEXEC_PRESERVE_CONTEXT) > > image->preserve_context = 1; > > -- > > 2.20.1 > > >