From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZykFk-0004XW-V6 for qemu-devel@nongnu.org; Tue, 17 Nov 2015 12:41:13 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZykFk-0005aQ-5i for qemu-devel@nongnu.org; Tue, 17 Nov 2015 12:41:12 -0500 Date: Tue, 17 Nov 2015 17:41:04 +0000 From: Keith Busch Message-ID: <20151117174104.GA22112@localhost.localdomain> References: <1447765689-28940-1-git-send-email-hch@lst.de> <1447765689-28940-2-git-send-email-hch@lst.de> <20151117172539.GA21832@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: Re: [Qemu-devel] [PATCH] nvme: fix identify to be NVMe 1.1 compliant List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Christoph Hellwig Cc: "qemu-devel@nongnu.org" , "qemu-block@nongnu.org" On Tue, Nov 17, 2015 at 09:33:11AM -0800, Busch, Keith wrote: > I accidently deleted my comment. Here's what it said: > > + list = g_malloc(data_len); > + for (i = 0; i < n->num_namespaces; i++) { > + if (i <= min_nsid) { > + continue; > + } > + list[i] = i; > > This should be: > > + list[i] = cpu_to_le32(i); Just saw this: we can't use the raw 'i' for the list index. It could return a badly formatted list if min_nsid is non-zero, or, even worse, corrupt memory if num_namsepaces > 1024. Need to do this instead: + list[i - min_nsid] = cpu_to_le32(i);