On 2017-09-15 08:05 AM, Hannes Reinecke wrote:
When calling SG_GET_REQUEST_TABLE ioctl that only a half-filled
table is returned; the remaining part will then contain stale
kernel memory information.
This patch zeroes out the entire table to avoid this issue.
Signed-off-by: Hannes Reinecke <hare@xxxxxxxx>
Acked-by: Douglas Gilbert <dgilbert@xxxxxxxxxxxx>
Thanks.
---
drivers/scsi/sg.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index f1e20ca0..7f98ab4 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -868,7 +868,6 @@ static int max_sectors_bytes(struct request_queue *q)
list_for_each_entry(srp, &sfp->rq_list, entry) {
if (val > SG_MAX_QUEUE)
break;
- memset(&rinfo[val], 0, SZ_SG_REQ_INFO);
rinfo[val].req_state = srp->done + 1;
rinfo[val].problem =
srp->header.masked_status &
@@ -1076,8 +1075,8 @@ static int max_sectors_bytes(struct request_queue *q)
else {
sg_req_info_t *rinfo;
- rinfo = kmalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
- GFP_KERNEL);
+ rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
+ GFP_KERNEL);
if (!rinfo)
return -ENOMEM;
read_lock_irqsave(&sfp->rq_list_lock, iflags);