Skip to content

Commit

Permalink
[SCSI] gdth: Add missing call to gdth_ioctl_free
Browse files Browse the repository at this point in the history
Add missing call to gdth_ioctl_free before aborting.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@@
expression buf,ha,len,addr,E;
@@

buf = gdth_ioctl_alloc(ha, len, FALSE, &addr)
... when != false buf != NULL
    when != true buf == NULL
    when != \(E = buf\|buf = E\)
    when != gdth_ioctl_free(ha, len, buf, addr)
*return ...;
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
  • Loading branch information
Julia Lawall authored and James Bottomley committed Dec 31, 2010
1 parent 8f4bfad commit 5c10007
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion drivers/scsi/gdth.c
Original file line number Diff line number Diff line change
Expand Up @@ -4273,8 +4273,10 @@ static int ioc_general(void __user *arg, char *cmnd)
}

rval = __gdth_execute(ha->sdev, &gen.command, cmnd, gen.timeout, &gen.info);
if (rval < 0)
if (rval < 0) {
gdth_ioctl_free(ha, gen.data_len+gen.sense_len, buf, paddr);
return rval;
}
gen.status = rval;

if (copy_to_user(arg + sizeof(gdth_ioctl_general), buf,
Expand Down
16 changes: 12 additions & 4 deletions drivers/scsi/gdth_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len = 0;
begin = pos;
}
if (pos > offset + length)
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
}
}
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
Expand Down Expand Up @@ -450,8 +452,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len = 0;
begin = pos;
}
if (pos > offset + length)
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
} while (drv_no != -1);

if (is_mirr) {
Expand All @@ -472,8 +476,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len = 0;
begin = pos;
}
if (pos > offset + length)
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
}
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);

Expand Down Expand Up @@ -542,8 +548,10 @@ static int gdth_get_info(char *buffer,char **start,off_t offset,int length,
len = 0;
begin = pos;
}
if (pos > offset + length)
if (pos > offset + length) {
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
goto stop_output;
}
}
}
gdth_ioctl_free(ha, GDTH_SCRATCH, buf, paddr);
Expand Down

0 comments on commit 5c10007

Please sign in to comment.