mbox series

[-next,0/3] nbd: fix null-ptr-dereference while accessing 'nbd->config'

Message ID 20230707031536.666482-1-zhongjinghua@huaweicloud.com (mailing list archive)
Headers show
Series nbd: fix null-ptr-dereference while accessing 'nbd->config' | expand

Message

zhongjinghua July 7, 2023, 3:15 a.m. UTC
From: Zhong Jinghua <zhongjinghua@huawei.com>

nbd->config = config and refcount_set(&nbd->config_refs, 1) in
nbd_genl_connect may be out of order, causing config_refs to be set to 1
first, and then nbd_open accessing nbd->config reports a null pointer
reference.

Zhong Jinghua (3):
  nbd: fold nbd config initialization into nbd_alloc_config()
  nbd: factor out a helper to get nbd_config without holding
    'config_lock'
  nbd: fix null-ptr-dereference while accessing 'nbd->config'

 drivers/block/nbd.c | 82 +++++++++++++++++++++++++++++----------------
 1 file changed, 53 insertions(+), 29 deletions(-)