Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 588F5606A320 for ; Mon, 30 Nov 2026 21:55:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KbcYRcKl; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=OpwGAGbf Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xY9LQ-0000tN-Dj; Mon, 30 Nov 2026 16:55:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xY9LB-0000B5-Rq for qemu-devel@nongnu.org; Mon, 30 Nov 2026 16:55:20 -0500 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xY9L9-00022x-A0 for qemu-devel@nongnu.org; Mon, 30 Nov 2026 16:55:17 -0500 Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6AUKQ9Mu3467224 for ; Mon, 30 Nov 2026 21:55:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= rJYmaot69L9WiaKNAg67msqQCAeEEnbB2W31LH/HE0s=; b=KbcYRcKlhirbCYD9 RH9PDlqjVCl2U/tCn6CPX1lVqdUuT/GpWmiFycr7VtB6DPX5SV1MhCrHpOMrdIoU YAoNEuWoeTeRfWiiIgAZI6l7efPkqp3w/IKuLq2IZ0t04wi+dm2ZJFO+YoMCw2Jw wn8nP6DgnTscRU6XQUbYsej1rLbNdsuwhcmmZmOwPwAdZiz+tgUZ1WVAXL8TkkdV 2p85n2YASV5fCs9ulOgTcKHNB//NNmGUNJ/suLGf2jfY+tJ3LMYuhRZQTpc3EUPr W5t9mSHHFZ1JrPha8OoLKYHd9V0E2dYsGLJ0N2wXUKnT2VlTsCQjuD8z9RBeSmJW D07iMg== Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4j9ffgrepd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 30 Nov 2026 21:55:12 +0000 (GMT) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-944138ed63fso1123363985a.3 for ; Mon, 30 Nov 2026 13:55:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796075712; x=1796680512; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=rJYmaot69L9WiaKNAg67msqQCAeEEnbB2W31LH/HE0s=; b=OpwGAGbfUIRhAm6AJYYV01FTph/CI6e2174CvzUl/akWAK+pn5hNqGnxNQu70oskiN hwzqqSMGGMwlU5SnCoEKOGZasHc0gXWljX3Bdwa6oQbkYA0abv4XimHT2tc7lQi7WjM1 oV65vwHE6qKnk3973GGiroE3TJqI2b5l09r8JcjBAq7HSrkMctrMDWFFDXZtb6IdRh6g QVanmPNlrvmiVYkHEqUOtnA1FdhEyuqk4RTzU7XPvLI4Ff+5uLMW581EtlBsKfvQ7ihJ HUdCkuBvu0B4cRgNpTcjir1Ad07KQC0uVh0EbRVSfXLYjycYZGG5S2lbq5DHjqqiJB6v t8cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796075712; x=1796680512; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=rJYmaot69L9WiaKNAg67msqQCAeEEnbB2W31LH/HE0s=; b=XtDwX+8a+pEGg14H4bONy/PxI0Z0LG2MK7UEfy/CUrlv2GskZWvPQKvh4TW9boF8T2 E9k/MjIop3aBk+Ey85OVqJEiSVHwzAV/Mo4gqcHjFZI+tlFFCu+CUjq0huKQs2+gU1SL xrnyG5os9Vmczfpw5ZhEhhpV5Xz0AEI9PT4VOA3lyPuPEow6n9ZfkY2KJOa5b4V9WT+X yiUWFWezT3+LLkD2+A6/Ifc/x6V4TGJ7xT3mZ8l7h20umyGAtc2E0gt7d21wI23kfNg7 ggSzqvsflh4RhtXYDxDUs5FDvD2wbq4yQHD6Ay/ogqFYk3h19V8I+kxMIO1QpVmRCsTR 517w== X-Gm-Message-State: APuU4Z8tBShDtQnGnHmysW6rHEO2Gfzru0PdeY0zYtyZ6UWCc3L3hmHE vTL6q6ARecdWePn6izIAvVutGO/JszqBVK462FhNYThnPJ+lY7v8wr81bZuuy7HbYziGoKe3xaP cOoJ5Q6tWKnmEgU38IyLQHDyHDvyjItdPJwWcW3jTdo71tOajZvmvgZgXVf5Ht+mFtw== X-Gm-Gg: AZFdTZc1HdcxsOimEQt5wEhGoa4tKAxqnKZr8FW2ip9xdLQdEBgAwIPILapmI7UxuUz wIYP8FND+7ogssvnDUsF7fAmFYWCygg+pqkYBsMw4OFOwE+LCodw0/Rrdz7vg4zmb2cYfCEcBab xPZX+PSx3qLPGxvF87J2ar6YZc+99vMmMD6B0RwZhFAiWMzbReft97nxt6yLzPhNMxFPhZcU63Q 4UDVhc6y3cBVtRf90HWOJLBtIfzbiX4ywP15U0FZ1tzDHftjBf7wHNY+ERvFj7tqJPTdrXSxckP 2hTHM877d2WTpzrhxXZ4s/jYq+Ba0cbAXUtcajuVTkruDruSdW3LScAOB/ATgFd0l119YKZVY5k 0DuWf9QYOT+xsyjhkIZ4JevWCLJKdJjAyLYTl2DD7p/zEajnhhpQZXeMwFSZLk+oYvA/vhJNW1G I6ot2EaFEqryx63gfgIytEm4Ht489DC0H7lNZZcjqm X-Received: by 2002:a05:620a:2995:b0:93f:43a4:a48c with SMTP id af79cd13be357-949baa0640dmr6564684285a.45.1796075711618; Mon, 30 Nov 2026 13:55:11 -0800 (PST) X-Received: by 2002:a05:620a:2995:b0:93f:43a4:a48c with SMTP id af79cd13be357-949baa0640dmr6564680385a.45.1796075711098; Mon, 30 Nov 2026 13:55:11 -0800 (PST) Received: from localhost.localdomain (alyon-655-1-564-32.w80-9.abo.wanadoo.fr. [80.9.105.32]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb853a12acsm979934355e9.8.2026.11.30.13.55.10 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 30 Nov 2026 13:55:10 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PULL 10/11] hw/block/pflash_cfi02: register VM change state handler once Date: Mon, 30 Nov 2026 22:53:59 +0100 Message-ID: <20261130215401.90201-11-philmd@oss.qualcomm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130215401.90201-1-philmd@oss.qualcomm.com> References: <20261130215401.90201-1-philmd@oss.qualcomm.com> X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMTMwMDA4OCBTYWx0ZWRfX6PZZBCjScnbQ 6N+XosGNP/MKZw10T3Q3ohFJAqlWO10IxDXYlSgitiZmdSHKqOSRkrEBYP1NeuO9DYe2fOSx6tv iY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ORIG-GUID: Cg3vuQWRDb66UJQWd5mh4Qi6mqXWuw8j X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-11-30_05,2026-11-30_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 spamscore=0 bulkscore=0 clxscore=1015 suspectscore=0 adultscore=0 phishscore=0 priorityscore=1501 lowpriorityscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2611300088 Received-SPF: pass client-ip=205.220.180.131; envelope-from=philmd@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org X-Spam-Status: No, score=-18.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_PASS, SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 From: Peter Maydell In the pflash_cfi02 post-load function we register a VM change state handler callback, which is a one-shot (it deletes itself when run). However, loading twice before the VM resumes means the post_load hook adds the handler again, overwriting the old pfl->vmstate. This can result in a use-after-free on resume because the first-registered callback does not delete itself (which is permitted) but the second-registered callback (which is not). Follow the pattern used by vapic.c and only register the callback if it has not already been registered. Cc: qemu-stable@nongnu.org Fixes: be71ba48d5c632 ("hw/block/pflash_cfi02: Add migration support") Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20261127144439.627586-4-peter.maydell@linaro.org> Signed-off-by: Philippe Mathieu-Daudé --- hw/block/pflash_cfi02.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/block/pflash_cfi02.c b/hw/block/pflash_cfi02.c index 8d130e14d1c1..28e8c27d72e8 100644 --- a/hw/block/pflash_cfi02.c +++ b/hw/block/pflash_cfi02.c @@ -1070,7 +1070,7 @@ static int pflash_post_load(void *opaque, int version_id) { PFlashCFI02 *pfl = opaque; - if (!pfl->ro) { + if (!pfl->ro && !pfl->vmstate) { pfl->vmstate = qemu_add_vm_change_state_handler(postload_update_cb, pfl); } -- 2.55.0