YueHaibing 12e750bc62 scsi: scsi_dh_alua: Fix possible null-ptr-deref
If alloc_workqueue fails in alua_init, it should return -ENOMEM, otherwise
it will trigger null-ptr-deref while unloading module which calls
destroy_workqueue dereference
wq->lock like this:

BUG: KASAN: null-ptr-deref in __lock_acquire+0x6b4/0x1ee0
Read of size 8 at addr 0000000000000080 by task syz-executor.0/7045

CPU: 0 PID: 7045 Comm: syz-executor.0 Tainted: G         C        5.1.0+ #28
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1
Call Trace:
 dump_stack+0xa9/0x10e
 __kasan_report+0x171/0x18d
 ? __lock_acquire+0x6b4/0x1ee0
 kasan_report+0xe/0x20
 __lock_acquire+0x6b4/0x1ee0
 lock_acquire+0xb4/0x1b0
 __mutex_lock+0xd8/0xb90
 drain_workqueue+0x25/0x290
 destroy_workqueue+0x1f/0x3f0
 __x64_sys_delete_module+0x244/0x330
 do_syscall_64+0x72/0x2a0
 entry_SYSCALL_64_after_hwframe+0x49/0xbe

Reported-by: Hulk Robot <hulkci@huawei.com>
Fixes: 03197b61c5ec ("scsi_dh_alua: Use workqueue for RTPG")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2019-05-29 22:04:09 -04:00
..
2018-12-18 23:19:21 -05:00
2019-03-19 17:38:20 -04:00
2019-03-09 16:53:47 -08:00
2019-03-09 16:53:47 -08:00
2019-03-09 16:53:47 -08:00
2019-03-02 11:39:54 -08:00
2018-12-18 23:19:21 -05:00
2018-12-18 23:19:21 -05:00
2018-06-19 22:02:25 -04:00
2018-12-18 23:19:21 -05:00
2019-01-08 21:58:35 -05:00
2019-01-08 21:58:35 -05:00
2018-12-18 23:19:21 -05:00
2018-12-28 14:48:06 -08:00
2019-03-18 16:46:14 -04:00
2018-12-18 23:13:12 -05:00
2018-12-18 23:19:21 -05:00
2018-11-06 21:31:28 -05:00
2019-03-09 16:53:47 -08:00
2019-03-16 12:51:50 -07:00
2018-12-18 23:19:21 -05:00
2019-02-05 21:28:52 -05:00
2018-12-28 14:48:06 -08:00
2019-05-20 10:56:43 -04:00
2018-12-18 23:13:12 -05:00
2019-03-09 16:53:47 -08:00
2018-06-04 07:58:06 -07:00
2018-06-19 22:02:25 -04:00
2019-02-12 22:33:00 -05:00
2018-06-12 16:19:22 -07:00
2018-12-18 23:19:21 -05:00
2019-02-05 21:29:49 -05:00
2018-12-18 23:19:21 -05:00
2018-12-28 14:48:06 -08:00