diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index b472bca5e..ed2a25e90 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -12487,8 +12487,10 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd, buffer_size = scst_get_buf_full(cmd, &buffer); sect_sz_off = opcode == READ_CAPACITY ? 4 : 8; - if (buffer_size < sect_sz_off + 4) + if (buffer_size < sect_sz_off + 4) { + scst_put_buf_full(cmd, buffer); goto out; + } sector_size = get_unaligned_be32(&buffer[sect_sz_off]); scst_put_buf_full(cmd, buffer); if (sector_size != 0) {