/[linux-patches]/genpatches-2.6/trunk/2.6.14/1174_5_scsi_lib-st-transfer-direction-fix.patch
Gentoo

Contents of /genpatches-2.6/trunk/2.6.14/1174_5_scsi_lib-st-transfer-direction-fix.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 292 - (show annotations) (download) (as text)
Tue Jan 31 21:50:53 2006 UTC (14 years, 9 months ago) by johnm
File MIME type: text/x-diff
File size: 3377 byte(s)
Large update - thanks goes to Kerin Millar for the legwork.
1 From: Stefan Richter <stefanr@s5r6.in-berlin.de>
2 Date: Wed, 14 Dec 2005 22:34:11 +0000 (+0100)
3 Subject: [PATCH] SCSI: fix transfer direction in scsi_lib and st
4 X-Git-Url: http://kernel.org/git/?p=linux/kernel/git/gregkh/linux-2.6.14.y.git;a=commitdiff;h=841f70676036b309f7102e2c8024dc68c3946990
5
6 [PATCH] SCSI: fix transfer direction in scsi_lib and st
7
8 SCSI: fix transfer direction in scsi_lib and st
9
10 scsi_prep_fn and st_init_command could issue WRITE requests with zero
11 buffer length. This may lead to kernel panic or oops with some SCSI
12 low-level drivers.
13
14 Derived from -rc patches from Jens Axboe and James Bottomley.
15
16 Patch is reassembled for -stable from patches:
17 [SCSI] fix panic when ejecting ieee1394 ipod
18 [SCSI] Consolidate REQ_BLOCK_PC handling path (fix ipod panic)
19
20 Depends on patch "SCSI: fix transfer direction in sd (kernel panic when
21 ejecting iPod)". Also modifies the already correct sr_init_command to
22 fully match the corresponding -rc patch.
23
24 Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
25 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
26 ---
27
28 --- a/drivers/scsi/scsi_lib.c
29 +++ b/drivers/scsi/scsi_lib.c
30 @@ -1284,18 +1284,7 @@ static int scsi_prep_fn(struct request_q
31 goto kill;
32 }
33 } else {
34 - memcpy(cmd->cmnd, req->cmd, sizeof(cmd->cmnd));
35 - cmd->cmd_len = req->cmd_len;
36 - if (rq_data_dir(req) == WRITE)
37 - cmd->sc_data_direction = DMA_TO_DEVICE;
38 - else if (req->data_len)
39 - cmd->sc_data_direction = DMA_FROM_DEVICE;
40 - else
41 - cmd->sc_data_direction = DMA_NONE;
42 -
43 - cmd->transfersize = req->data_len;
44 - cmd->allowed = 3;
45 - cmd->timeout_per_command = req->timeout;
46 + scsi_setup_blk_pc_cmnd(cmd, 3);
47 cmd->done = scsi_generic_done;
48 }
49 }
50 --- a/drivers/scsi/sr.c
51 +++ b/drivers/scsi/sr.c
52 @@ -320,25 +320,11 @@ static int sr_init_command(struct scsi_c
53 * these are already setup, just copy cdb basically
54 */
55 if (SCpnt->request->flags & REQ_BLOCK_PC) {
56 - struct request *rq = SCpnt->request;
57 + scsi_setup_blk_pc_cmnd(SCpnt, MAX_RETRIES);
58
59 - if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
60 - return 0;
61 -
62 - memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
63 - SCpnt->cmd_len = rq->cmd_len;
64 - if (!rq->data_len)
65 - SCpnt->sc_data_direction = DMA_NONE;
66 - else if (rq_data_dir(rq) == WRITE)
67 - SCpnt->sc_data_direction = DMA_TO_DEVICE;
68 - else
69 - SCpnt->sc_data_direction = DMA_FROM_DEVICE;
70 -
71 - this_count = rq->data_len;
72 - if (rq->timeout)
73 - timeout = rq->timeout;
74 + if (SCpnt->timeout_per_command)
75 + timeout = SCpnt->timeout_per_command;
76
77 - SCpnt->transfersize = rq->data_len;
78 goto queue;
79 }
80
81 --- a/drivers/scsi/st.c
82 +++ b/drivers/scsi/st.c
83 @@ -4196,27 +4196,10 @@ static void st_intr(struct scsi_cmnd *SC
84 */
85 static int st_init_command(struct scsi_cmnd *SCpnt)
86 {
87 - struct request *rq;
88 -
89 if (!(SCpnt->request->flags & REQ_BLOCK_PC))
90 return 0;
91
92 - rq = SCpnt->request;
93 - if (sizeof(rq->cmd) > sizeof(SCpnt->cmnd))
94 - return 0;
95 -
96 - memcpy(SCpnt->cmnd, rq->cmd, sizeof(SCpnt->cmnd));
97 - SCpnt->cmd_len = rq->cmd_len;
98 -
99 - if (rq_data_dir(rq) == WRITE)
100 - SCpnt->sc_data_direction = DMA_TO_DEVICE;
101 - else if (rq->data_len)
102 - SCpnt->sc_data_direction = DMA_FROM_DEVICE;
103 - else
104 - SCpnt->sc_data_direction = DMA_NONE;
105 -
106 - SCpnt->timeout_per_command = rq->timeout;
107 - SCpnt->transfersize = rq->data_len;
108 + scsi_setup_blk_pc_cmnd(SCpnt, 0);
109 SCpnt->done = st_intr;
110 return 1;
111 }

  ViewVC Help
Powered by ViewVC 1.1.20