Skip to contentSkip to conversation

video:uvesafb: notice user when we failed to save hardware state

PATCH Applied Wang YanQing 2 participants 2 messages Mar 2, 2012 – Mar 21, 2012 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 video:uvesafb: notice user when we failed to save hardware state

uvesafb_open may failed to save hardware state when kmalloc failed in uvesafb_vbe_state_save, we should check this and notice user.

---
 drivers/video/uvesafb.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/video/uvesafb.c +11 -3
index e7f69ef..9db3de3 100644
@@ -362,7 +362,7 @@ static u8 *uvesafb_vbe_state_save(struct uvesafb_par *par)
 
 	state = kmalloc(par->vbe_state_size, GFP_KERNEL);
 	if (!state)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	task = uvesafb_prep();
 	if (!task) {
@@ -1172,9 +1172,17 @@ static int uvesafb_open(struct fb_info *info, int user)
 {
 	struct uvesafb_par *par = info->par;
 	int cnt = atomic_read(&par->ref_count);
+	u8 *buf = NULL;
 
-	if (!cnt && par->vbe_state_size)
-		par->vbe_state_orig = uvesafb_vbe_state_save(par);
+	if (!cnt && par->vbe_state_size) {
+		buf =  uvesafb_vbe_state_save(par);
+		if (IS_ERR(buf)) {
+			printk(KERN_WARNING "uvesafb: save hardware state"
+				"failed, error code is %ld!\n", PTR_ERR(buf));
+		} else {
+			par->vbe_state_orig = buf;
+		}
+	}
 
 	atomic_inc(&par->ref_count);
 	return 0;
Signature · 1 line
1.7.9.2.315.g25a78
#1 lore raw
Quoted 5 lines · Wang YanQing

uvesafb_open may failed to save hardware state when kmalloc failed in uvesafb_vbe_state_save, we should check this and notice user.

Applied.

Thanks,

Florian Tobias Schandinat

Quoted 37 lines
---
 drivers/video/uvesafb.c |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
drivers/video/uvesafb.c +11 -3
index e7f69ef..9db3de3 100644
@@ -362,7 +362,7 @@ static u8 *uvesafb_vbe_state_save(struct uvesafb_par *par)
 
 	state = kmalloc(par->vbe_state_size, GFP_KERNEL);
 	if (!state)
-		return NULL;
+		return ERR_PTR(-ENOMEM);
 
 	task = uvesafb_prep();
 	if (!task) {
@@ -1172,9 +1172,17 @@ static int uvesafb_open(struct fb_info *info, int user)
 {
 	struct uvesafb_par *par = info->par;
 	int cnt = atomic_read(&par->ref_count);
+	u8 *buf = NULL;
 
-	if (!cnt && par->vbe_state_size)
-		par->vbe_state_orig = uvesafb_vbe_state_save(par);
+	if (!cnt && par->vbe_state_size) {
+		buf =  uvesafb_vbe_state_save(par);
+		if (IS_ERR(buf)) {
+			printk(KERN_WARNING "uvesafb: save hardware state"
+				"failed, error code is %ld!\n", PTR_ERR(buf));
+		} else {
+			par->vbe_state_orig = buf;
+		}
+	}
 
 	atomic_inc(&par->ref_count);
 	return 0;