[patch] hvc_xen: NULL dereference on allocation failure

Subsystems: hypervisor virtual console driver, the rest, tty layer and serial drivers

STALE5221d

3 messages, 3 authors, 2012-05-21 · open the first message on its own page

[patch] hvc_xen: NULL dereference on allocation failure

From: Dan Carpenter <hidden>
Date: 2012-05-15 08:48:34

If kzalloc() returns a NULL here, we pass a NULL to
xencons_disconnect_backend() which will cause an Oops.

Also I removed the __GFP_ZERO while I was at it since kzalloc() implies
__GFP_ZERO.

Signed-off-by: Dan Carpenter <redacted>
diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c
index 83d5c88..d3d91da 100644
--- a/drivers/tty/hvc/hvc_xen.c
+++ b/drivers/tty/hvc/hvc_xen.c
@@ -430,9 +430,9 @@ static int __devinit xencons_probe(struct xenbus_device *dev,
 	if (devid == 0)
 		return -ENODEV;
 
-	info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL | __GFP_ZERO);
+	info = kzalloc(sizeof(struct xencons_info), GFP_KERNEL);
 	if (!info)
-		goto error_nomem;
+		return -ENOMEM;
 	dev_set_drvdata(&dev->dev, info);
 	info->xbdev = dev;
 	info->vtermno = xenbus_devid_to_vtermno(devid);

Re: [patch] hvc_xen: NULL dereference on allocation failure

From: Stefano Stabellini <hidden>
Date: 2012-05-15 10:21:09

On Tue, 15 May 2012, Dan Carpenter wrote:
If kzalloc() returns a NULL here, we pass a NULL to
xencons_disconnect_backend() which will cause an Oops.

Also I removed the __GFP_ZERO while I was at it since kzalloc() implies
__GFP_ZERO.

Signed-off-by: Dan Carpenter <redacted>
Acked-by: Stefano Stabellini <redacted>
 

Re: [patch] hvc_xen: NULL dereference on allocation failure

From: Konrad Rzeszutek Wilk <hidden>
Date: 2012-05-21 15:43:41

On Tue, May 15, 2012 at 11:20:23AM +0100, Stefano Stabellini wrote:
On Tue, 15 May 2012, Dan Carpenter wrote:
quoted
If kzalloc() returns a NULL here, we pass a NULL to
xencons_disconnect_backend() which will cause an Oops.

Also I removed the __GFP_ZERO while I was at it since kzalloc() implies
__GFP_ZERO.

Signed-off-by: Dan Carpenter <redacted>
Acked-by: Stefano Stabellini <redacted>
applied.
 
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help