From patchwork Wed Sep 12 12:32:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Qiang X-Patchwork-Id: 10597423 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 22C82921 for ; Wed, 12 Sep 2018 12:33:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 121BC28F75 for ; Wed, 12 Sep 2018 12:33:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 055A828FD0; Wed, 12 Sep 2018 12:33:06 +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_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,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 7ADD728F75 for ; Wed, 12 Sep 2018 12:33:04 +0000 (UTC) Received: from localhost ([::1]:36011 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04KN-0003ZP-LY for patchwork-qemu-devel@patchwork.kernel.org; Wed, 12 Sep 2018 08:33:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53539) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g04Jh-0003CV-47 for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:32:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g04Je-0001kM-0S for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:32:21 -0400 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:44133) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g04Jd-0001jL-CN for qemu-devel@nongnu.org; Wed, 12 Sep 2018 08:32:17 -0400 Received: by mail-pg1-x542.google.com with SMTP id r1-v6so985439pgp.11 for ; Wed, 12 Sep 2018 05:32:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=y7KRlZ/3DfLqZuL5Bh3fywtC0qx8BQ5mgDQrRD6vIV0=; b=DDv3gJ6/F4om3fs5zW7kDG66lCGyzLH7vqEtK63/nu+7i7C8vCbPv53kDPLEc6nAeL NOYUWNvdjPhKzLVURW1bTcX0HmQF7AQ+HT8rkQo5Xl3pQTnU5ptiKmWqBEbFFeD7kP/v DZEIWMiimWn7MT/4qD0gJnjy4jhUhH8uUwspGhmW48sfEwTZrwm+Qty7Xmgbj6esWaiC AulAWcdOFs/6uxshAHF+B0nftj7h4HB1ysXIu7Ai6YtK9q9DQXcN29SZmg43pM2WWuzk uHcuFl/kNdjM/AGgmItWd+z5GfzTaYrBWSY6c4HBww7lnEKxyGBEioioFoOLXyF4Ji/z 55mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=y7KRlZ/3DfLqZuL5Bh3fywtC0qx8BQ5mgDQrRD6vIV0=; b=QKt4IR8tm5S7/pLpdpLftSN0OqvdzARnrY8td/NB0HBk5kEGGucdefDiTRJizeUdRK PBNaYzAy25hyahfrcULcX0F88tEIsRgcjiqMrhcOb6QO6XF5qAv0tjNL4tIgSdxDDiUX wKxVDv8St/rLccxbqjBr67UrQQkhmlppeoewUrbwDFHVPxpSNZyHveygLGRv9kV/POnB /Wlw3b0CG0/eWsiTDyKWfVw+sjNe8rr6l33WhQ0dzchLPNL7dezsYRcPfOgRcaZHaCMk 5nUKh+a8jKv1n1Wlq8oFTBT/vTgTUbCUtfMG3o6AqxvvdU6iXEagy+u50XF9oY9Rn3vd C3Wg== X-Gm-Message-State: APzg51CRc90T9BkzUVi4Tfk6D99gSLpQskdqORJOtM1AbJsawCfitQb/ k6NQ/nYI3X3BNUqrnl8d9T0= X-Google-Smtp-Source: ANB0VdYBRAjdr+lO5aJMvkc21PS6EsxhTkviC0K2coJflO3Xg6wp2eTrIvDCe00Jsk/xjogtltt73A== X-Received: by 2002:a63:7e1c:: with SMTP id z28-v6mr2027205pgc.246.1536755535959; Wed, 12 Sep 2018 05:32:15 -0700 (PDT) Received: from localhost.localdomain.localdomain ([103.65.40.65]) by smtp.gmail.com with ESMTPSA id m26-v6sm2985190pfi.102.2018.09.12.05.32.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Sep 2018 05:32:15 -0700 (PDT) From: Li Qiang To: mst@redhat.com, ehabkost@redhat.com, marcandre.lureau@gmail.com, lersek@redhat.com, peter.maydell@linaro.org, pbonzini@redhat.com, ppandit@redhat.com Date: Wed, 12 Sep 2018 05:32:09 -0700 Message-Id: <1536755529-2709-1-git-send-email-liq3ea@gmail.com> X-Mailer: git-send-email 1.8.3.1 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::542 Subject: [Qemu-devel] [PATCH] memory region: check the old.mmio.read status 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: Li Qiang , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP To avoid NULL-deref for the devices without read callbacks Signed-off-by: Li Qiang --- memory.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/memory.c b/memory.c index 9b73892768..48d025426b 100644 --- a/memory.c +++ b/memory.c @@ -406,6 +406,10 @@ static MemTxResult memory_region_oldmmio_read_accessor(MemoryRegion *mr, { uint64_t tmp; + if (!mr->ops->old_mmio.read[ctz32(size)]) { + return MEMTX_DECODE_ERROR; + } + tmp = mr->ops->old_mmio.read[ctz32(size)](mr->opaque, addr); if (mr->subpage) { trace_memory_region_subpage_read(get_cpu_index(), mr, addr, tmp, size);