Commit a4d56cc4 authored by Douglas Gilbert's avatar Douglas Gilbert Committed by James Bottomley

[PATCH] sg jiffy library calls [was: sg kill local jiffies

Douglas Gilbert wrote:
> It has been reported that the change to sg.c in lk 2.6.9-rc1-bk5
> to use library jiffy functions breaks sg (albeit under vmware).
> Evidentally sg devices are no longer recognised after that change.
> 
> Reverting that changeset removes the problem. Strange, it is not
> obvious why.
> 
> At some stage I must have detected negative time spans (yeh yeh it
> never happens) and my versions returned 0 in this case; otherwise
> the implementations look very similar.

The following patch fixes the problem. It is
against lk 2.6.9-rc1-bk7 (i.e. after "standard"
jiffy_to_millisecs macros replaced sg versions).

Change:
    - make sure a (large) user supplied timeout value does
      not result in a negative timeout passed to the midlevel
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 8b0f49f5
......@@ -589,6 +589,7 @@ sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count,
sg_io_hdr_t *hp;
unsigned char cmnd[sizeof (dummy_cmdp->sr_cmnd)];
int timeout;
unsigned long ul_timeout;
if (count < SZ_SG_IO_HDR)
return -EINVAL;
......@@ -623,7 +624,8 @@ sg_new_write(Sg_fd * sfp, const char __user *buf, size_t count,
return -EBUSY; /* reserve buffer already being used */
}
}
timeout = msecs_to_jiffies(srp->header.timeout);
ul_timeout = msecs_to_jiffies(srp->header.timeout);
timeout = (ul_timeout < INT_MAX) ? ul_timeout : INT_MAX;
if ((!hp->cmdp) || (hp->cmd_len < 6) || (hp->cmd_len > sizeof (cmnd))) {
sg_remove_request(sfp, srp);
return -EMSGSIZE;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment