Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

virtio-mem: fix sleeping in RCU read side section in virtio_mem_online_page_cb()

virtio_mem_set_fake_offline() might sleep now, and we call it under
rcu_read_lock(). To fix it, simply move the rcu_read_unlock() further
up, as we're done with the device.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 6cc26d77613a: "virtio-mem: use page_offline_(start|end) when setting PageOffline()
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Jason Wang <jasowang@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: virtualization@lists.linux-foundation.org
Signed-off-by: David Hildenbrand <david@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Hildenbrand and committed by
Linus Torvalds
425bec00 5a61b7a2

+8 -1
+8 -1
drivers/virtio/virtio_mem.c
··· 1242 1242 do_online = virtio_mem_bbm_get_bb_state(vm, id) != 1243 1243 VIRTIO_MEM_BBM_BB_FAKE_OFFLINE; 1244 1244 } 1245 + 1246 + /* 1247 + * virtio_mem_set_fake_offline() might sleep, we don't need 1248 + * the device anymore. See virtio_mem_remove() how races 1249 + * between memory onlining and device removal are handled. 1250 + */ 1251 + rcu_read_unlock(); 1252 + 1245 1253 if (do_online) 1246 1254 generic_online_page(page, order); 1247 1255 else 1248 1256 virtio_mem_set_fake_offline(PFN_DOWN(addr), 1 << order, 1249 1257 false); 1250 - rcu_read_unlock(); 1251 1258 return; 1252 1259 } 1253 1260 rcu_read_unlock();