aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorMichal Feix <michal@feix.cz>2006-07-30 06:03:31 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-07-31 16:28:39 -0400
commite4b57e0842621f597d744b193ea325d62724596b (patch)
tree0cb75aac6d4452d95dfe8ab1931bed45b1246bb9 /drivers/block
parent8e185d83398b2708f50207bc12d0e0a70bd70767 (diff)
[PATCH] nbd: Check magic before doing anything else
We should check magic sequence in reply packet before trying to find request with it's request handle. This also solves the problem with "Unexpected reply" message beeing logged, when packet with invalid magic is received. Signed-off-by: Michal Feix <michal@feix.cz> Acked-by: Paul Clements <paul.clements@steeleye.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/nbd.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 0a1b1ea36ddc..31a0b605f261 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -300,6 +300,15 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
300 lo->disk->disk_name, result); 300 lo->disk->disk_name, result);
301 goto harderror; 301 goto harderror;
302 } 302 }
303
304 if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
305 printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
306 lo->disk->disk_name,
307 (unsigned long)ntohl(reply.magic));
308 result = -EPROTO;
309 goto harderror;
310 }
311
303 req = nbd_find_request(lo, reply.handle); 312 req = nbd_find_request(lo, reply.handle);
304 if (unlikely(IS_ERR(req))) { 313 if (unlikely(IS_ERR(req))) {
305 result = PTR_ERR(req); 314 result = PTR_ERR(req);
@@ -312,13 +321,6 @@ static struct request *nbd_read_stat(struct nbd_device *lo)
312 goto harderror; 321 goto harderror;
313 } 322 }
314 323
315 if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
316 printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
317 lo->disk->disk_name,
318 (unsigned long)ntohl(reply.magic));
319 result = -EPROTO;
320 goto harderror;
321 }
322 if (ntohl(reply.error)) { 324 if (ntohl(reply.error)) {
323 printk(KERN_ERR "%s: Other side returned error (%d)\n", 325 printk(KERN_ERR "%s: Other side returned error (%d)\n",
324 lo->disk->disk_name, ntohl(reply.error)); 326 lo->disk->disk_name, ntohl(reply.error));