From patchwork Thu Aug 9 14:14:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olaf Hering X-Patchwork-Id: 10561453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 52FF21057 for ; Thu, 9 Aug 2018 14:15:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 422E92B541 for ; Thu, 9 Aug 2018 14:15:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3551A2B54B; Thu, 9 Aug 2018 14:15:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id EA2242B541 for ; Thu, 9 Aug 2018 14:15:09 +0000 (UTC) Received: from localhost ([::1]:51063 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnliW-0008Ra-Mo for patchwork-qemu-devel@patchwork.kernel.org; Thu, 09 Aug 2018 10:15:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnlhb-0007VB-G3 for qemu-devel@nongnu.org; Thu, 09 Aug 2018 10:14:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnlha-0000V8-KL for qemu-devel@nongnu.org; Thu, 09 Aug 2018 10:14:11 -0400 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::6]:16269) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fnlha-0000Tu-4X for qemu-devel@nongnu.org; Thu, 09 Aug 2018 10:14:10 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1533824046; s=strato-dkim-0002; d=aepfle.de; h=Message-Id:Date:Subject:Cc:To:From:X-RZG-CLASS-ID:X-RZG-AUTH:From: Subject:Sender; bh=OBx8toP7oIPYH8aif9f6Nps7g1Op096+qk1dtYdUJJc=; b=AzWEMHjDwuGcZoE9iPQow1ltu9Lj1p1n/6HF31XogGIWvCCpL4yxUsqit36yaMP753 2ekhogeSmmvyRVQP1OI0yjNpUJ03tHZ+pM1wNkqlCvHDQgjCsVBnM3fG9oghoqHQSjae qvtB8IpJjHUkxnowxi1T/SVBytSnxGeVIxQqmCLKvcPrSsGvu9yB7HJz37pdhFyDlRfb ERyQ4N6tD4ElsQmMy2oxecGXB0AM/rQZrQqaOilzQCqZpWhwrA+JoPRjSiCKWJ2JfQ42 LiDQnt5+IcrTkogkskMfvewppzM0fJx0yVqokScgp52jb4QM4UELi3odAcrpWfh8bKW/ 7K7w== X-RZG-AUTH: ":P2EQZWCpfu+qG7CngxMFH1J+3q8wa/QXkBR9MXjAuzpOGUivpc0WAr0t3Sj8140FKdfYth0=" X-RZG-CLASS-ID: mo00 Received: from sender by smtp.strato.de (RZmta 43.15 AUTH) with ESMTPSA id d07a67u79EE46TC (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Thu, 9 Aug 2018 16:14:04 +0200 (CEST) From: Olaf Hering To: Paolo Bonzini , Peter Crosthwaite , Richard Henderson , qemu-devel@nongnu.org (open list:Overall) Date: Thu, 9 Aug 2018 16:14:03 +0200 Message-Id: <20180809141403.11296-1-olaf@aepfle.de> X-Mailer: git-send-email 2.16.4 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 2a01:238:20a:202:5300::6 Subject: [Qemu-devel] [PATCH v1] exec: handle NULL pointer in flatview_read_continue X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Olaf Hering Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The codepaths behind qemu_ram_ptr_length can return NULL. Avoid crashing the device-model in such case, just move on. Signed-off-by: Olaf Hering --- This happens if calling xendevicemodel_create_ioreq_server() is disabled, and eventually if that function returns an error. --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index 4f5df07b6a..0d30e48571 100644 --- a/exec.c +++ b/exec.c @@ -3318,7 +3318,8 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, } else { /* RAM case */ ptr = qemu_ram_ptr_length(mr->ram_block, addr1, &l, false); - memcpy(buf, ptr, l); + if (ptr) + memcpy(buf, ptr, l); } if (release_lock) {