From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36578) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gMVKS-0000eD-F1 for qemu-devel@nongnu.org; Tue, 13 Nov 2018 04:49:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gMVKR-0005QN-FK for qemu-devel@nongnu.org; Tue, 13 Nov 2018 04:49:52 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:37756) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gMVKR-0005PO-0Y for qemu-devel@nongnu.org; Tue, 13 Nov 2018 04:49:51 -0500 Received: by mail-ot1-x341.google.com with SMTP id 40so10754240oth.4 for ; Tue, 13 Nov 2018 01:49:48 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <1542073341-2843-1-git-send-email-liq3ea@gmail.com> References: <1542073341-2843-1-git-send-email-liq3ea@gmail.com> From: Peter Maydell Date: Tue, 13 Nov 2018 09:49:28 +0000 Message-ID: Content-Type: text/plain; charset="UTF-8" Subject: Re: [Qemu-devel] [PATCH] memory: check write/read_with_attrs in memory dispatch List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Li Qiang Cc: Paolo Bonzini , =?UTF-8?B?TWFyYy1BbmRyw6kgTHVyZWF1?= , P J P , QEMU Developers On 13 November 2018 at 01:42, Li Qiang wrote: > This can avoid the NULL-deref if the rm doesn't has a > read/write nor write/read_with_attrs callback. > > Signed-off-by: Li Qiang > --- > memory.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) Alternative approach -- assert that every MemoryRegionOps has pointers to callbacks in it, when it is registered in memory_region_init_io() and memory_region_init_rom_device_nomigrate(). I don't have a strong opinion on which is better, but I guess I slightly favour requiring devices to be specific about what their read/write behaviour is. Do we have many devices that legitimately only want to implement one of read and write, not both ? thanks -- PMM