* [PATCH] nbd: Check magic before doing anything else
@ 2006-07-16 13:06 Michal Feix
2006-07-17 15:30 ` Paul Clements
0 siblings, 1 reply; 2+ messages in thread
From: Michal Feix @ 2006-07-16 13:06 UTC (permalink / raw)
To: Paul.Clements; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 274 bytes --]
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>
---
[-- Attachment #2: nbd.c.magic-check.diff --]
[-- Type: text/plain, Size: 1082 bytes --]
diff -upr 2.6.18-rc2.orig/drivers/block/nbd.c 2.6.18-rc2/drivers/block/nbd.c
--- 2.6.18-rc2.orig/drivers/block/nbd.c 2006-07-16 14:34:09.106878500 +0200
+++ 2.6.18-rc2/drivers/block/nbd.c 2006-07-16 14:48:59.000000000 +0200
@@ -300,6 +300,15 @@ static struct request *nbd_read_stat(str
lo->disk->disk_name, result);
goto harderror;
}
+
+ if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
+ printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
+ lo->disk->disk_name,
+ (unsigned long)ntohl(reply.magic));
+ result = -EPROTO;
+ goto harderror;
+ }
+
req = nbd_find_request(lo, reply.handle);
if (unlikely(IS_ERR(req))) {
result = PTR_ERR(req);
@@ -312,13 +321,6 @@ static struct request *nbd_read_stat(str
goto harderror;
}
- if (ntohl(reply.magic) != NBD_REPLY_MAGIC) {
- printk(KERN_ERR "%s: Wrong magic (0x%lx)\n",
- lo->disk->disk_name,
- (unsigned long)ntohl(reply.magic));
- result = -EPROTO;
- goto harderror;
- }
if (ntohl(reply.error)) {
printk(KERN_ERR "%s: Other side returned error (%d)\n",
lo->disk->disk_name, ntohl(reply.error));
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] nbd: Check magic before doing anything else
2006-07-16 13:06 [PATCH] nbd: Check magic before doing anything else Michal Feix
@ 2006-07-17 15:30 ` Paul Clements
0 siblings, 0 replies; 2+ messages in thread
From: Paul Clements @ 2006-07-17 15:30 UTC (permalink / raw)
To: Michal Feix, akpm; +Cc: linux-kernel
Michal Feix wrote:
> 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.
Right. Again, we can't return NULL after pulling the request off the
queue, so we better do this check first.
Andrew, these two look good to me.
Thanks,
Paul
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-07-17 15:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-16 13:06 [PATCH] nbd: Check magic before doing anything else Michal Feix
2006-07-17 15:30 ` Paul Clements
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox