scsi: lib/sg_pool.c: clear 'first_chunk' in case of no preallocation
authorMing Lei <ming.lei@redhat.com>
Thu, 6 Jun 2019 08:34:08 +0000 (16:34 +0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 20 Jun 2019 19:21:33 +0000 (15:21 -0400)
commitb79d9a09ae23c7047bdce3a15e284398334198ea
treeb2cdeab4564fdd2bc3706eb1aa0864e3e4ec1e6f
parent3dccdf53c2f38399b11085ded4447ce1467f006c
scsi: lib/sg_pool.c: clear 'first_chunk' in case of no preallocation

If user doesn't ask to preallocate by passing zero 'nents_first_chunk' to
sg_alloc_table_chained, we need to make sure that 'first_chunk' is cleared.
Otherwise, __sg_alloc_table() still may think that the 1st SGL should be
from the preallocation.

Fixes the issue by clearing 'first_chunk' in sg_alloc_table_chained() if
'nents_first_chunk' is zero.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Bart Van Assche <bvanassche@acm.org>
Cc: Ewan D. Milne <emilne@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: Guenter Roeck <linux@roeck-us.net>
Reported-by: Guenter Roeck <linux@roeck-us.net>
Tested-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Ming Lei <ming.lei@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
lib/sg_pool.c