Skip to content

Commit

Permalink
Staging: asus_oled: Add NULL test for kmalloc
Browse files Browse the repository at this point in the history
This patch adds a NULL test to check wether kmalloc was successful or
not.

Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Peter Huewe authored and Greg Kroah-Hartman committed Mar 4, 2010
1 parent c424d46 commit 0df28be
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/staging/asus_oled/asus_oled.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,11 @@ static ssize_t odev_set_picture(struct asus_oled_dev *odev,

kfree(odev->buf);
odev->buf = kmalloc(odev->buf_size, GFP_KERNEL);
if (odev->buf == NULL) {
odev->buf_size = 0;
printk(ASUS_OLED_ERROR "Out of memory!\n");
return -ENOMEM;
}

memset(odev->buf, 0xff, odev->buf_size);

Expand Down

0 comments on commit 0df28be

Please sign in to comment.