All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations
@ 2017-11-25 20:42   ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:42 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:38:42 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  Delete an error message for a failed memory allocation in two functions
  Less checks in ufx_usb_probe() after error detection
  Return an error code only as a constant in ufx_realloc_framebuffer()
  Improve a size determination in two functions
  Adjust three checks for null pointers

 drivers/video/fbdev/smscufx.c | 80 ++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 51 deletions(-)

-- 
2.15.0

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations
@ 2017-11-25 20:42   ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:42 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:38:42 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  Delete an error message for a failed memory allocation in two functions
  Less checks in ufx_usb_probe() after error detection
  Return an error code only as a constant in ufx_realloc_framebuffer()
  Improve a size determination in two functions
  Adjust three checks for null pointers

 drivers/video/fbdev/smscufx.c | 80 ++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 51 deletions(-)

-- 
2.15.0



^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations
@ 2017-11-25 20:42   ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:42 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:38:42 +0100

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (5):
  Delete an error message for a failed memory allocation in two functions
  Less checks in ufx_usb_probe() after error detection
  Return an error code only as a constant in ufx_realloc_framebuffer()
  Improve a size determination in two functions
  Adjust three checks for null pointers

 drivers/video/fbdev/smscufx.c | 80 ++++++++++++++++---------------------------
 1 file changed, 29 insertions(+), 51 deletions(-)

-- 
2.15.0


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH 1/5] video: smscufx: Delete an error message for a failed memory allocation in two functions
  2017-11-25 20:42   ` SF Markus Elfring
  (?)
@ 2017-11-25 20:44     ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:44 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 18:32:29 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 2275e80b5776..32de07d77184 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1309,10 +1309,8 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		 * Alloc system memory for virtual framebuffer
 		 */
 		new_fb = vmalloc(new_len);
-		if (!new_fb) {
-			pr_err("Virtual framebuffer alloc failed");
+		if (!new_fb)
 			goto error;
-		}
 
 		if (info->screen_base) {
 			memcpy(new_fb, old_fb, old_len);
@@ -1630,10 +1628,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	BUG_ON(!usbdev);
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (dev == NULL) {
-		dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n");
+	if (!dev)
 		goto error;
-	}
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 1/5] video: smscufx: Delete an error message for a failed memory allocation in two functions
@ 2017-11-25 20:44     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:44 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 18:32:29 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 2275e80b5776..32de07d77184 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1309,10 +1309,8 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		 * Alloc system memory for virtual framebuffer
 		 */
 		new_fb = vmalloc(new_len);
-		if (!new_fb) {
-			pr_err("Virtual framebuffer alloc failed");
+		if (!new_fb)
 			goto error;
-		}
 
 		if (info->screen_base) {
 			memcpy(new_fb, old_fb, old_len);
@@ -1630,10 +1628,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	BUG_ON(!usbdev);
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (dev = NULL) {
-		dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n");
+	if (!dev)
 		goto error;
-	}
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 1/5] video: smscufx: Delete an error message for a failed memory allocation in two functions
@ 2017-11-25 20:44     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:44 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 18:32:29 +0100

Omit an extra message for a memory allocation failure in these functions.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 2275e80b5776..32de07d77184 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1309,10 +1309,8 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		 * Alloc system memory for virtual framebuffer
 		 */
 		new_fb = vmalloc(new_len);
-		if (!new_fb) {
-			pr_err("Virtual framebuffer alloc failed");
+		if (!new_fb)
 			goto error;
-		}
 
 		if (info->screen_base) {
 			memcpy(new_fb, old_fb, old_len);
@@ -1630,10 +1628,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	BUG_ON(!usbdev);
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
-	if (dev == NULL) {
-		dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n");
+	if (!dev)
 		goto error;
-	}
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
-- 
2.15.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 2/5] video: smscufx: Less checks in ufx_usb_probe() after error detection
  2017-11-25 20:42   ` SF Markus Elfring
@ 2017-11-25 20:45     ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:45 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 19:47:51 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 45 +++++++++++++++++--------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 32de07d77184..08271dafd138 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1619,8 +1619,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1629,7 +1629,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		goto error;
+		return -ENOMEM;
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
@@ -1649,9 +1649,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1659,9 +1658,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1672,7 +1670,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1733,26 +1731,19 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 2/5] video: smscufx: Less checks in ufx_usb_probe() after error detection
@ 2017-11-25 20:45     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:45 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 19:47:51 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 45 +++++++++++++++++--------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 32de07d77184..08271dafd138 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1619,8 +1619,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1629,7 +1629,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		goto error;
+		return -ENOMEM;
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
@@ -1649,9 +1649,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1659,9 +1658,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1672,7 +1670,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1733,26 +1731,19 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 3/5] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer()
  2017-11-25 20:42   ` SF Markus Elfring
@ 2017-11-25 20:46     ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:46 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 19:56:44 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the label "error" and local variable "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 08271dafd138..c77fc45a76fc 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1294,7 +1294,6 @@ static struct fb_ops ufx_ops = {
  * Assumes no active clients have framebuffer open */
 static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 {
-	int retval = -ENOMEM;
 	int old_len = info->fix.smem_len;
 	int new_len;
 	unsigned char *old_fb = info->screen_base;
@@ -1310,7 +1309,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		 */
 		new_fb = vmalloc(new_len);
 		if (!new_fb)
-			goto error;
+			return -ENOMEM;
 
 		if (info->screen_base) {
 			memcpy(new_fb, old_fb, old_len);
@@ -1322,11 +1321,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		info->fix.smem_start = (unsigned long) new_fb;
 		info->flags = smscufx_info_flags;
 	}
-
-	retval = 0;
-
-error:
-	return retval;
+	return 0;
 }
 
 /* sets up I2C Controller for 100 Kbps, std. speed, 7-bit addr, master,
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 3/5] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer()
@ 2017-11-25 20:46     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:46 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 19:56:44 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the label "error" and local variable "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 08271dafd138..c77fc45a76fc 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1294,7 +1294,6 @@ static struct fb_ops ufx_ops = {
  * Assumes no active clients have framebuffer open */
 static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 {
-	int retval = -ENOMEM;
 	int old_len = info->fix.smem_len;
 	int new_len;
 	unsigned char *old_fb = info->screen_base;
@@ -1310,7 +1309,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		 */
 		new_fb = vmalloc(new_len);
 		if (!new_fb)
-			goto error;
+			return -ENOMEM;
 
 		if (info->screen_base) {
 			memcpy(new_fb, old_fb, old_len);
@@ -1322,11 +1321,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		info->fix.smem_start = (unsigned long) new_fb;
 		info->flags = smscufx_info_flags;
 	}
-
-	retval = 0;
-
-error:
-	return retval;
+	return 0;
 }
 
 /* sets up I2C Controller for 100 Kbps, std. speed, 7-bit addr, master,
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 4/5] video: smscufx: Improve a size determination in two functions
  2017-11-25 20:42   ` SF Markus Elfring
  (?)
@ 2017-11-25 20:47     ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:47 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:10:22 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index c77fc45a76fc..03d35429e1b9 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1086,8 +1086,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
 
 		struct fb_deferred_io *fbdefio;
 
-		fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
-
+		fbdefio = kzalloc(sizeof(*fbdefio), GFP_KERNEL);
 		if (fbdefio) {
 			fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
 			fbdefio->deferred_io = ufx_dpy_deferred_io;
@@ -1857,7 +1856,7 @@ static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size)
 	INIT_LIST_HEAD(&dev->urbs.list);
 
 	while (i < count) {
-		unode = kzalloc(sizeof(struct urb_node), GFP_KERNEL);
+		unode = kzalloc(sizeof(*unode), GFP_KERNEL);
 		if (!unode)
 			break;
 		unode->dev = dev;
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 4/5] video: smscufx: Improve a size determination in two functions
@ 2017-11-25 20:47     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:47 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:10:22 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index c77fc45a76fc..03d35429e1b9 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1086,8 +1086,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
 
 		struct fb_deferred_io *fbdefio;
 
-		fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
-
+		fbdefio = kzalloc(sizeof(*fbdefio), GFP_KERNEL);
 		if (fbdefio) {
 			fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
 			fbdefio->deferred_io = ufx_dpy_deferred_io;
@@ -1857,7 +1856,7 @@ static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size)
 	INIT_LIST_HEAD(&dev->urbs.list);
 
 	while (i < count) {
-		unode = kzalloc(sizeof(struct urb_node), GFP_KERNEL);
+		unode = kzalloc(sizeof(*unode), GFP_KERNEL);
 		if (!unode)
 			break;
 		unode->dev = dev;
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 4/5] video: smscufx: Improve a size determination in two functions
@ 2017-11-25 20:47     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:47 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:10:22 +0100

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index c77fc45a76fc..03d35429e1b9 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1086,8 +1086,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
 
 		struct fb_deferred_io *fbdefio;
 
-		fbdefio = kzalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
-
+		fbdefio = kzalloc(sizeof(*fbdefio), GFP_KERNEL);
 		if (fbdefio) {
 			fbdefio->delay = UFX_DEFIO_WRITE_DELAY;
 			fbdefio->deferred_io = ufx_dpy_deferred_io;
@@ -1857,7 +1856,7 @@ static int ufx_alloc_urb_list(struct ufx_data *dev, int count, size_t size)
 	INIT_LIST_HEAD(&dev->urbs.list);
 
 	while (i < count) {
-		unode = kzalloc(sizeof(struct urb_node), GFP_KERNEL);
+		unode = kzalloc(sizeof(*unode), GFP_KERNEL);
 		if (!unode)
 			break;
 		unode->dev = dev;
-- 
2.15.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 5/5] video: smscufx: Adjust three checks for null pointers
  2017-11-25 20:42   ` SF Markus Elfring
  (?)
@ 2017-11-25 20:50     ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:50 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:21:20 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 03d35429e1b9..d14604536e63 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1081,7 +1081,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
 
 	kref_get(&dev->kref);
 
-	if (fb_defio && (info->fbdefio == NULL)) {
+	if (fb_defio && !info->fbdefio) {
 		/* enable defio at last moment if not disabled by client */
 
 		struct fb_deferred_io *fbdefio;
@@ -1556,8 +1556,7 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 	}
 
 	/* If everything else has failed, fall back to safe default mode */
-	if (default_vmode == NULL) {
-
+	if (!default_vmode) {
 		struct fb_videomode fb_vmode = {0};
 
 		/* Add the standard VESA modes to our modelist
@@ -1583,8 +1582,7 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 	}
 
 	/* If we have good mode and no active clients */
-	if ((default_vmode != NULL) && (dev->fb_count == 0)) {
-
+	if (default_vmode && dev->fb_count == 0) {
 		fb_videomode_to_var(&info->var, default_vmode);
 		ufx_var_color_format(&info->var);
 
@@ -1594,10 +1592,9 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 			(info->var.bits_per_pixel / 8);
 
 		result = ufx_realloc_framebuffer(dev, info);
-
-	} else
+	} else {
 		result = -EINVAL;
-
+	}
 error:
 	if (edid && (dev->edid != edid))
 		kfree(edid);
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 5/5] video: smscufx: Adjust three checks for null pointers
@ 2017-11-25 20:50     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:50 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:21:20 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 03d35429e1b9..d14604536e63 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1081,7 +1081,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
 
 	kref_get(&dev->kref);
 
-	if (fb_defio && (info->fbdefio = NULL)) {
+	if (fb_defio && !info->fbdefio) {
 		/* enable defio at last moment if not disabled by client */
 
 		struct fb_deferred_io *fbdefio;
@@ -1556,8 +1556,7 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 	}
 
 	/* If everything else has failed, fall back to safe default mode */
-	if (default_vmode = NULL) {
-
+	if (!default_vmode) {
 		struct fb_videomode fb_vmode = {0};
 
 		/* Add the standard VESA modes to our modelist
@@ -1583,8 +1582,7 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 	}
 
 	/* If we have good mode and no active clients */
-	if ((default_vmode != NULL) && (dev->fb_count = 0)) {
-
+	if (default_vmode && dev->fb_count = 0) {
 		fb_videomode_to_var(&info->var, default_vmode);
 		ufx_var_color_format(&info->var);
 
@@ -1594,10 +1592,9 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 			(info->var.bits_per_pixel / 8);
 
 		result = ufx_realloc_framebuffer(dev, info);
-
-	} else
+	} else {
 		result = -EINVAL;
-
+	}
 error:
 	if (edid && (dev->edid != edid))
 		kfree(edid);
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH 5/5] video: smscufx: Adjust three checks for null pointers
@ 2017-11-25 20:50     ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-25 20:50 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sat, 25 Nov 2017 21:21:20 +0100
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

The script “checkpatch.pl” pointed information out like the following.

Comparison to NULL could be written …

Thus fix the affected source code places.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/video/fbdev/smscufx.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 03d35429e1b9..d14604536e63 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1081,7 +1081,7 @@ static int ufx_ops_open(struct fb_info *info, int user)
 
 	kref_get(&dev->kref);
 
-	if (fb_defio && (info->fbdefio == NULL)) {
+	if (fb_defio && !info->fbdefio) {
 		/* enable defio at last moment if not disabled by client */
 
 		struct fb_deferred_io *fbdefio;
@@ -1556,8 +1556,7 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 	}
 
 	/* If everything else has failed, fall back to safe default mode */
-	if (default_vmode == NULL) {
-
+	if (!default_vmode) {
 		struct fb_videomode fb_vmode = {0};
 
 		/* Add the standard VESA modes to our modelist
@@ -1583,8 +1582,7 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 	}
 
 	/* If we have good mode and no active clients */
-	if ((default_vmode != NULL) && (dev->fb_count == 0)) {
-
+	if (default_vmode && dev->fb_count == 0) {
 		fb_videomode_to_var(&info->var, default_vmode);
 		ufx_var_color_format(&info->var);
 
@@ -1594,10 +1592,9 @@ static int ufx_setup_modes(struct ufx_data *dev, struct fb_info *info,
 			(info->var.bits_per_pixel / 8);
 
 		result = ufx_realloc_framebuffer(dev, info);
-
-	} else
+	} else {
 		result = -EINVAL;
-
+	}
 error:
 	if (edid && (dev->edid != edid))
 		kfree(edid);
-- 
2.15.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v2 2/5] video: smscufx: Less checks in ufx_usb_probe() after error detection
  2017-11-25 20:45     ` SF Markus Elfring
  (?)
@ 2017-11-26  7:38       ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-26  7:38 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 26 Nov 2017 08:18:20 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
A call of the function "fb_dealloc_cmap" was preserved for the exception
handling at the end.

 drivers/video/fbdev/smscufx.c | 46 ++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 32de07d77184..a48a2dec3f5e 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1619,8 +1619,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1629,7 +1629,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		goto error;
+		return -ENOMEM;
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
@@ -1649,9 +1649,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1659,9 +1658,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1672,7 +1670,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1733,26 +1731,20 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+	fb_dealloc_cmap(&info->cmap);
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.0

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v2 2/5] video: smscufx: Less checks in ufx_usb_probe() after error detection
@ 2017-11-26  7:38       ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-26  7:38 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 26 Nov 2017 08:18:20 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
A call of the function "fb_dealloc_cmap" was preserved for the exception
handling at the end.

 drivers/video/fbdev/smscufx.c | 46 ++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 32de07d77184..a48a2dec3f5e 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1619,8 +1619,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1629,7 +1629,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		goto error;
+		return -ENOMEM;
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
@@ -1649,9 +1649,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1659,9 +1658,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1672,7 +1670,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1733,26 +1731,20 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+	fb_dealloc_cmap(&info->cmap);
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.0


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v2 2/5] video: smscufx: Less checks in ufx_usb_probe() after error detection
@ 2017-11-26  7:38       ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-11-26  7:38 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 26 Nov 2017 08:18:20 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v2:
A call of the function "fb_dealloc_cmap" was preserved for the exception
handling at the end.

 drivers/video/fbdev/smscufx.c | 46 ++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 32de07d77184..a48a2dec3f5e 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1619,8 +1619,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1629,7 +1629,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
-		goto error;
+		return -ENOMEM;
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
 	kref_init(&dev->kref); /* matching kref_put in usb .disconnect fn */
@@ -1649,9 +1649,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1659,9 +1658,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1672,7 +1670,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1733,26 +1731,20 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+	fb_dealloc_cmap(&info->cmap);
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* Re: [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations
  2017-11-25 20:42   ` SF Markus Elfring
  (?)
@ 2017-12-29 18:26     ` Bartlomiej Zolnierkiewicz
  -1 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2017-12-29 18:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-fbdev, dri-devel, Steve Glendinning, LKML, kernel-janitors

On Saturday, November 25, 2017 09:42:57 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 25 Nov 2017 21:38:42 +0100
> 
> A few update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (5):
>   Delete an error message for a failed memory allocation in two functions

This patch removes the information about the device for which the allocation
fails.

>   Less checks in ufx_usb_probe() after error detection

This patch depends on the earlier patch (which is not being merged) so please
re-base it if you want it to be applied.

>   Return an error code only as a constant in ufx_realloc_framebuffer()

ditto

>   Improve a size determination in two functions

Patch queued for 4.16, thanks.

>   Adjust three checks for null pointers

This patch contains unrelated change ({} braces addition) which should be
dropped.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations
@ 2017-12-29 18:26     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2017-12-29 18:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Steve Glendinning, linux-fbdev, kernel-janitors, LKML, dri-devel

On Saturday, November 25, 2017 09:42:57 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 25 Nov 2017 21:38:42 +0100
> 
> A few update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (5):
>   Delete an error message for a failed memory allocation in two functions

This patch removes the information about the device for which the allocation
fails.

>   Less checks in ufx_usb_probe() after error detection

This patch depends on the earlier patch (which is not being merged) so please
re-base it if you want it to be applied.

>   Return an error code only as a constant in ufx_realloc_framebuffer()

ditto

>   Improve a size determination in two functions

Patch queued for 4.16, thanks.

>   Adjust three checks for null pointers

This patch contains unrelated change ({} braces addition) which should be
dropped.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations
@ 2017-12-29 18:26     ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2017-12-29 18:26 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Steve Glendinning, linux-fbdev, kernel-janitors, LKML, dri-devel

On Saturday, November 25, 2017 09:42:57 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 25 Nov 2017 21:38:42 +0100
> 
> A few update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (5):
>   Delete an error message for a failed memory allocation in two functions

This patch removes the information about the device for which the allocation
fails.

>   Less checks in ufx_usb_probe() after error detection

This patch depends on the earlier patch (which is not being merged) so please
re-base it if you want it to be applied.

>   Return an error code only as a constant in ufx_realloc_framebuffer()

ditto

>   Improve a size determination in two functions

Patch queued for 4.16, thanks.

>   Adjust three checks for null pointers

This patch contains unrelated change ({} braces addition) which should be
dropped.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [0/5] video-SMSC UFX: Adjustments for five function implementations
  2017-12-29 18:26     ` Bartlomiej Zolnierkiewicz
@ 2017-12-29 18:43       ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-12-29 18:43 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, linux-fbdev, dri-devel
  Cc: Steve Glendinning, LKML, kernel-janitors

>>   Delete an error message for a failed memory allocation in two functions
> 
> This patch removes the information about the device for which the allocation fails.

Should a Linux allocation failure report be sufficient here?


>>   Less checks in ufx_usb_probe() after error detection
> 
> This patch depends on the earlier patch (which is not being merged)

Partly, yes.


> so please re-base it if you want it to be applied.

Would you dare to pick another change possibility up from a patch hunk?


>>   Adjust three checks for null pointers
> 
> This patch contains unrelated change ({} braces addition) which should be dropped.

I presented such an update approach so that warnings from the script “checkpatch.pl”
will be fixed together.

Regards,
Markus

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [0/5] video-SMSC UFX: Adjustments for five function implementations
@ 2017-12-29 18:43       ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2017-12-29 18:43 UTC (permalink / raw)
  To: Bartlomiej Zolnierkiewicz, linux-fbdev, dri-devel
  Cc: Steve Glendinning, LKML, kernel-janitors

>>   Delete an error message for a failed memory allocation in two functions
> 
> This patch removes the information about the device for which the allocation fails.

Should a Linux allocation failure report be sufficient here?


>>   Less checks in ufx_usb_probe() after error detection
> 
> This patch depends on the earlier patch (which is not being merged)

Partly, yes.


> so please re-base it if you want it to be applied.

Would you dare to pick another change possibility up from a patch hunk?


>>   Adjust three checks for null pointers
> 
> This patch contains unrelated change ({} braces addition) which should be dropped.

I presented such an update approach so that warnings from the script “checkpatch.pl”
will be fixed together.

Regards,
Markus

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH v3 0/3] video-SMSC UFX: Adjustments for two function implementations
  2017-12-29 18:26     ` Bartlomiej Zolnierkiewicz
  (?)
@ 2018-01-07 16:00       ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:00 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:54:32 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Less checks in ufx_usb_probe() after error detection
  Return an error code only as a constant
    in ufx_realloc_framebuffer()
  Delete an error message for a failed memory allocation
    in ufx_realloc_framebuffer()

---

v3:
Rebased on Linux next-20180105.

 drivers/video/fbdev/smscufx.c | 59 ++++++++++++++++---------------------------
 1 file changed, 22 insertions(+), 37 deletions(-)

-- 
2.15.1

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH v3 0/3] video-SMSC UFX: Adjustments for two function implementations
@ 2018-01-07 16:00       ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:00 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:54:32 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Less checks in ufx_usb_probe() after error detection
  Return an error code only as a constant
    in ufx_realloc_framebuffer()
  Delete an error message for a failed memory allocation
    in ufx_realloc_framebuffer()

---

v3:
Rebased on Linux next-20180105.

 drivers/video/fbdev/smscufx.c | 59 ++++++++++++++++---------------------------
 1 file changed, 22 insertions(+), 37 deletions(-)

-- 
2.15.1


^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH v3 0/3] video-SMSC UFX: Adjustments for two function implementations
@ 2018-01-07 16:00       ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:00 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:54:32 +0100

Three update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
  Less checks in ufx_usb_probe() after error detection
  Return an error code only as a constant
    in ufx_realloc_framebuffer()
  Delete an error message for a failed memory allocation
    in ufx_realloc_framebuffer()

---

v3:
Rebased on Linux next-20180105.

 drivers/video/fbdev/smscufx.c | 59 ++++++++++++++++---------------------------
 1 file changed, 22 insertions(+), 37 deletions(-)

-- 
2.15.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* [PATCH v3 1/3] video: smscufx: Less checks in ufx_usb_probe() after error detection
  2018-01-07 16:00       ` SF Markus Elfring
  (?)
@ 2018-01-07 16:02         ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:02 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 15:56:11 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

v2:
A call of the function "fb_dealloc_cmap" was preserved for the exception
handling at the end.

 drivers/video/fbdev/smscufx.c | 46 ++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 8db7085e5d1a..893daeb1ffd9 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1620,8 +1620,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1631,7 +1631,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
 		dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n");
-		goto error;
+		return -ENOMEM;
 	}
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
@@ -1652,9 +1652,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1662,9 +1661,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1675,7 +1673,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1736,26 +1734,20 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+	fb_dealloc_cmap(&info->cmap);
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 1/3] video: smscufx: Less checks in ufx_usb_probe() after error detection
@ 2018-01-07 16:02         ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:02 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 15:56:11 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

v2:
A call of the function "fb_dealloc_cmap" was preserved for the exception
handling at the end.

 drivers/video/fbdev/smscufx.c | 46 ++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 8db7085e5d1a..893daeb1ffd9 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1620,8 +1620,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1631,7 +1631,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev = NULL) {
 		dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n");
-		goto error;
+		return -ENOMEM;
 	}
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
@@ -1652,9 +1652,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1662,9 +1661,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1675,7 +1673,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1736,26 +1734,20 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+	fb_dealloc_cmap(&info->cmap);
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 1/3] video: smscufx: Less checks in ufx_usb_probe() after error detection
@ 2018-01-07 16:02         ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:02 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 15:56:11 +0100

Up to four checks could be repeated by the ufx_usb_probe() function
during error handling even if the relevant properties can be determined
for the involved variables before by source code analysis.

* Return directly after a call of the function "kzalloc" failed
  at the beginning.

* Adjust jump targets so that extra checks can be omitted at the end.

* Delete initialisations for the variables "info" and "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

v2:
A call of the function "fb_dealloc_cmap" was preserved for the exception
handling at the end.

 drivers/video/fbdev/smscufx.c | 46 ++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 27 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 8db7085e5d1a..893daeb1ffd9 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1620,8 +1620,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 {
 	struct usb_device *usbdev;
 	struct ufx_data *dev;
-	struct fb_info *info = NULL;
-	int retval = -ENOMEM;
+	struct fb_info *info;
+	int retval;
 	u32 id_rev, fpga_rev;
 
 	/* usb initialization */
@@ -1631,7 +1631,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (dev == NULL) {
 		dev_err(&usbdev->dev, "ufx_usb_probe: failed alloc of dev struct\n");
-		goto error;
+		return -ENOMEM;
 	}
 
 	/* we need to wait for both usb and fbdev to spin down on disconnect */
@@ -1652,9 +1652,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	dev_dbg(dev->gdev, "fb_defio enable=%d\n", fb_defio);
 
 	if (!ufx_alloc_urb_list(dev, WRITES_IN_FLIGHT, MAX_TRANSFER)) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "ufx_alloc_urb_list failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	/* We don't register a new USB class. Our client interface is fbdev */
@@ -1662,9 +1661,8 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	/* allocates framebuffer driver structure, not framebuffer memory */
 	info = framebuffer_alloc(0, &usbdev->dev);
 	if (!info) {
-		retval = -ENOMEM;
 		dev_err(dev->gdev, "framebuffer_alloc failed\n");
-		goto error;
+		goto e_nomem;
 	}
 
 	dev->info = info;
@@ -1675,7 +1673,7 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	retval = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (retval < 0) {
 		dev_err(dev->gdev, "fb_alloc_cmap failed %x\n", retval);
-		goto error;
+		goto destroy_modedb;
 	}
 
 	INIT_DELAYED_WORK(&dev->free_framebuffer_work,
@@ -1736,26 +1734,20 @@ static int ufx_usb_probe(struct usb_interface *interface,
 	return 0;
 
 error:
-	if (dev) {
-		if (info) {
-			if (info->cmap.len != 0)
-				fb_dealloc_cmap(&info->cmap);
-			if (info->monspecs.modedb)
-				fb_destroy_modedb(info->monspecs.modedb);
-			vfree(info->screen_base);
-
-			fb_destroy_modelist(&info->modelist);
-
-			framebuffer_release(info);
-		}
-
-		kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
-		kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
-
-		/* dev has been deallocated. Do not dereference */
-	}
-
+	fb_dealloc_cmap(&info->cmap);
+destroy_modedb:
+	fb_destroy_modedb(info->monspecs.modedb);
+	vfree(info->screen_base);
+	fb_destroy_modelist(&info->modelist);
+	framebuffer_release(info);
+put_ref:
+	kref_put(&dev->kref, ufx_free); /* ref for framebuffer */
+	kref_put(&dev->kref, ufx_free); /* last ref from kref_init */
 	return retval;
+
+e_nomem:
+	retval = -ENOMEM;
+	goto put_ref;
 }
 
 static void ufx_usb_disconnect(struct usb_interface *interface)
-- 
2.15.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer()
  2018-01-07 16:00       ` SF Markus Elfring
  (?)
@ 2018-01-07 16:04         ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:04 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:07:11 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the label "error" and local variable "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

 drivers/video/fbdev/smscufx.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 893daeb1ffd9..abbded605d68 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1293,7 +1293,6 @@ static struct fb_ops ufx_ops = {
  * Assumes no active clients have framebuffer open */
 static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 {
-	int retval = -ENOMEM;
 	int old_len = info->fix.smem_len;
 	int new_len;
 	unsigned char *old_fb = info->screen_base;
@@ -1310,7 +1309,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		new_fb = vmalloc(new_len);
 		if (!new_fb) {
 			pr_err("Virtual framebuffer alloc failed");
-			goto error;
+			return -ENOMEM;
 		}
 
 		if (info->screen_base) {
@@ -1323,11 +1322,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		info->fix.smem_start = (unsigned long) new_fb;
 		info->flags = smscufx_info_flags;
 	}
-
-	retval = 0;
-
-error:
-	return retval;
+	return 0;
 }
 
 /* sets up I2C Controller for 100 Kbps, std. speed, 7-bit addr, master,
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer()
@ 2018-01-07 16:04         ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:04 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:07:11 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the label "error" and local variable "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

 drivers/video/fbdev/smscufx.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 893daeb1ffd9..abbded605d68 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1293,7 +1293,6 @@ static struct fb_ops ufx_ops = {
  * Assumes no active clients have framebuffer open */
 static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 {
-	int retval = -ENOMEM;
 	int old_len = info->fix.smem_len;
 	int new_len;
 	unsigned char *old_fb = info->screen_base;
@@ -1310,7 +1309,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		new_fb = vmalloc(new_len);
 		if (!new_fb) {
 			pr_err("Virtual framebuffer alloc failed");
-			goto error;
+			return -ENOMEM;
 		}
 
 		if (info->screen_base) {
@@ -1323,11 +1322,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		info->fix.smem_start = (unsigned long) new_fb;
 		info->flags = smscufx_info_flags;
 	}
-
-	retval = 0;
-
-error:
-	return retval;
+	return 0;
 }
 
 /* sets up I2C Controller for 100 Kbps, std. speed, 7-bit addr, master,
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer()
@ 2018-01-07 16:04         ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:04 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: kernel-janitors, LKML

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:07:11 +0100

* Return an error code without storing it in an intermediate variable.

* Delete the label "error" and local variable "retval"
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

 drivers/video/fbdev/smscufx.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index 893daeb1ffd9..abbded605d68 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1293,7 +1293,6 @@ static struct fb_ops ufx_ops = {
  * Assumes no active clients have framebuffer open */
 static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 {
-	int retval = -ENOMEM;
 	int old_len = info->fix.smem_len;
 	int new_len;
 	unsigned char *old_fb = info->screen_base;
@@ -1310,7 +1309,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		new_fb = vmalloc(new_len);
 		if (!new_fb) {
 			pr_err("Virtual framebuffer alloc failed");
-			goto error;
+			return -ENOMEM;
 		}
 
 		if (info->screen_base) {
@@ -1323,11 +1322,7 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		info->fix.smem_start = (unsigned long) new_fb;
 		info->flags = smscufx_info_flags;
 	}
-
-	retval = 0;
-
-error:
-	return retval;
+	return 0;
 }
 
 /* sets up I2C Controller for 100 Kbps, std. speed, 7-bit addr, master,
-- 
2.15.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc_framebuffer()
  2018-01-07 16:00       ` SF Markus Elfring
@ 2018-01-07 16:06         ` SF Markus Elfring
  -1 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:06 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:12:40 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

 drivers/video/fbdev/smscufx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index abbded605d68..22b606af0a87 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1307,10 +1307,8 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		 * Alloc system memory for virtual framebuffer
 		 */
 		new_fb = vmalloc(new_len);
-		if (!new_fb) {
-			pr_err("Virtual framebuffer alloc failed");
+		if (!new_fb)
 			return -ENOMEM;
-		}
 
 		if (info->screen_base) {
 			memcpy(new_fb, old_fb, old_len);
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 43+ messages in thread

* [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc
@ 2018-01-07 16:06         ` SF Markus Elfring
  0 siblings, 0 replies; 43+ messages in thread
From: SF Markus Elfring @ 2018-01-07 16:06 UTC (permalink / raw)
  To: linux-fbdev, dri-devel, Bartlomiej Zolnierkiewicz, Steve Glendinning
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Sun, 7 Jan 2018 16:12:40 +0100

Omit an extra message for a memory allocation failure in this function.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---

v3:
This update suggestion was rebased on source files from the software
"Linux next-20180105".

 drivers/video/fbdev/smscufx.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/video/fbdev/smscufx.c b/drivers/video/fbdev/smscufx.c
index abbded605d68..22b606af0a87 100644
--- a/drivers/video/fbdev/smscufx.c
+++ b/drivers/video/fbdev/smscufx.c
@@ -1307,10 +1307,8 @@ static int ufx_realloc_framebuffer(struct ufx_data *dev, struct fb_info *info)
 		 * Alloc system memory for virtual framebuffer
 		 */
 		new_fb = vmalloc(new_len);
-		if (!new_fb) {
-			pr_err("Virtual framebuffer alloc failed");
+		if (!new_fb)
 			return -ENOMEM;
-		}
 
 		if (info->screen_base) {
 			memcpy(new_fb, old_fb, old_len);
-- 
2.15.1


^ permalink raw reply related	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 1/3] video: smscufx: Less checks in ufx_usb_probe() after error detection
  2018-01-07 16:02         ` SF Markus Elfring
@ 2018-03-28 13:46           ` Bartlomiej Zolnierkiewicz
  -1 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-fbdev, dri-devel, Steve Glendinning, LKML, kernel-janitors

On Sunday, January 07, 2018 05:02:21 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 15:56:11 +0100
> 
> Up to four checks could be repeated by the ufx_usb_probe() function
> during error handling even if the relevant properties can be determined
> for the involved variables before by source code analysis.
> 
> * Return directly after a call of the function "kzalloc" failed
>   at the beginning.
> 
> * Adjust jump targets so that extra checks can be omitted at the end.
> 
> * Delete initialisations for the variables "info" and "retval"
>   which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 1/3] video: smscufx: Less checks in ufx_usb_probe() after error detection
@ 2018-03-28 13:46           ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:46 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-fbdev, dri-devel, Steve Glendinning, LKML, kernel-janitors

On Sunday, January 07, 2018 05:02:21 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 15:56:11 +0100
> 
> Up to four checks could be repeated by the ufx_usb_probe() function
> during error handling even if the relevant properties can be determined
> for the involved variables before by source code analysis.
> 
> * Return directly after a call of the function "kzalloc" failed
>   at the beginning.
> 
> * Adjust jump targets so that extra checks can be omitted at the end.
> 
> * Delete initialisations for the variables "info" and "retval"
>   which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer()
  2018-01-07 16:04         ` SF Markus Elfring
  (?)
@ 2018-03-28 13:48           ` Bartlomiej Zolnierkiewicz
  -1 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-fbdev, dri-devel, Steve Glendinning, LKML, kernel-janitors

On Sunday, January 07, 2018 05:04:04 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 16:07:11 +0100
> 
> * Return an error code without storing it in an intermediate variable.
> 
> * Delete the label "error" and local variable "retval"
>   which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffe
@ 2018-03-28 13:48           ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Steve Glendinning, linux-fbdev, kernel-janitors, LKML, dri-devel

On Sunday, January 07, 2018 05:04:04 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 16:07:11 +0100
> 
> * Return an error code without storing it in an intermediate variable.
> 
> * Delete the label "error" and local variable "retval"
>   which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer()
@ 2018-03-28 13:48           ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:48 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Steve Glendinning, linux-fbdev, kernel-janitors, LKML, dri-devel

On Sunday, January 07, 2018 05:04:04 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 16:07:11 +0100
> 
> * Return an error code without storing it in an intermediate variable.
> 
> * Delete the label "error" and local variable "retval"
>   which became unnecessary with this refactoring.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc_framebuffer()
  2018-01-07 16:06         ` [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc SF Markus Elfring
  (?)
@ 2018-03-28 13:51           ` Bartlomiej Zolnierkiewicz
  -1 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: linux-fbdev, dri-devel, Steve Glendinning, LKML, kernel-janitors

On Sunday, January 07, 2018 05:06:13 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 16:12:40 +0100
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_rea
@ 2018-03-28 13:51           ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Steve Glendinning, linux-fbdev, kernel-janitors, LKML, dri-devel

On Sunday, January 07, 2018 05:06:13 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 16:12:40 +0100
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics


^ permalink raw reply	[flat|nested] 43+ messages in thread

* Re: [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc_framebuffer()
@ 2018-03-28 13:51           ` Bartlomiej Zolnierkiewicz
  0 siblings, 0 replies; 43+ messages in thread
From: Bartlomiej Zolnierkiewicz @ 2018-03-28 13:51 UTC (permalink / raw)
  To: SF Markus Elfring
  Cc: Steve Glendinning, linux-fbdev, kernel-janitors, LKML, dri-devel

On Sunday, January 07, 2018 05:06:13 PM SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sun, 7 Jan 2018 16:12:40 +0100
> 
> Omit an extra message for a memory allocation failure in this function.
> 
> This issue was detected by using the Coccinelle software.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

Patch queued for 4.17, thanks.

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 43+ messages in thread

end of thread, other threads:[~2018-03-28 13:51 UTC | newest]

Thread overview: 43+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CGME20171125204312epcas2p149d6487ac83e886f95aefe0b35aef1b0@epcas2p1.samsung.com>
2017-11-25 20:42 ` [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations SF Markus Elfring
2017-11-25 20:42   ` SF Markus Elfring
2017-11-25 20:42   ` SF Markus Elfring
2017-11-25 20:44   ` [PATCH 1/5] video: smscufx: Delete an error message for a failed memory allocation in two functions SF Markus Elfring
2017-11-25 20:44     ` SF Markus Elfring
2017-11-25 20:44     ` SF Markus Elfring
2017-11-25 20:45   ` [PATCH 2/5] video: smscufx: Less checks in ufx_usb_probe() after error detection SF Markus Elfring
2017-11-25 20:45     ` SF Markus Elfring
2017-11-26  7:38     ` [PATCH v2 " SF Markus Elfring
2017-11-26  7:38       ` SF Markus Elfring
2017-11-26  7:38       ` SF Markus Elfring
2017-11-25 20:46   ` [PATCH 3/5] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer() SF Markus Elfring
2017-11-25 20:46     ` SF Markus Elfring
2017-11-25 20:47   ` [PATCH 4/5] video: smscufx: Improve a size determination in two functions SF Markus Elfring
2017-11-25 20:47     ` SF Markus Elfring
2017-11-25 20:47     ` SF Markus Elfring
2017-11-25 20:50   ` [PATCH 5/5] video: smscufx: Adjust three checks for null pointers SF Markus Elfring
2017-11-25 20:50     ` SF Markus Elfring
2017-11-25 20:50     ` SF Markus Elfring
2017-12-29 18:26   ` [PATCH 0/5] video-SMSC UFX: Adjustments for five function implementations Bartlomiej Zolnierkiewicz
2017-12-29 18:26     ` Bartlomiej Zolnierkiewicz
2017-12-29 18:26     ` Bartlomiej Zolnierkiewicz
2017-12-29 18:43     ` [0/5] " SF Markus Elfring
2017-12-29 18:43       ` SF Markus Elfring
2018-01-07 16:00     ` [PATCH v3 0/3] video-SMSC UFX: Adjustments for two " SF Markus Elfring
2018-01-07 16:00       ` SF Markus Elfring
2018-01-07 16:00       ` SF Markus Elfring
2018-01-07 16:02       ` [PATCH v3 1/3] video: smscufx: Less checks in ufx_usb_probe() after error detection SF Markus Elfring
2018-01-07 16:02         ` SF Markus Elfring
2018-01-07 16:02         ` SF Markus Elfring
2018-03-28 13:46         ` Bartlomiej Zolnierkiewicz
2018-03-28 13:46           ` Bartlomiej Zolnierkiewicz
2018-01-07 16:04       ` [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffer() SF Markus Elfring
2018-01-07 16:04         ` SF Markus Elfring
2018-01-07 16:04         ` SF Markus Elfring
2018-03-28 13:48         ` Bartlomiej Zolnierkiewicz
2018-03-28 13:48           ` Bartlomiej Zolnierkiewicz
2018-03-28 13:48           ` [PATCH v3 2/3] video: smscufx: Return an error code only as a constant in ufx_realloc_framebuffe Bartlomiej Zolnierkiewicz
2018-01-07 16:06       ` [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc_framebuffer() SF Markus Elfring
2018-01-07 16:06         ` [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc SF Markus Elfring
2018-03-28 13:51         ` [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_realloc_framebuffer() Bartlomiej Zolnierkiewicz
2018-03-28 13:51           ` Bartlomiej Zolnierkiewicz
2018-03-28 13:51           ` [PATCH v3 3/3] video: smscufx: Delete an error message for a failed memory allocation in ufx_rea Bartlomiej Zolnierkiewicz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.