Skip to contentSkip to conversation

Cypress: Adjustments for cypress_load_firmware()

PATCH New SF Markus Elfring 1 participant 3 messages Aug 28, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover Cypress: Adjustments for cypress_load_firmware()

From: Markus Elfring <[email protected]>
Date: Mon, 28 Aug 2017 12:00:21 +0200

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

Markus Elfring (2):
Delete an error message for a failed memory allocation Improve a size determination

 drivers/media/common/cypress_firmware.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/2 Cypress: Delete an error message for a failed memory allocation in cypress_load_firmware()

From: Markus Elfring <[email protected]>
Date: Mon, 28 Aug 2017 11:46:57 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/media/common/cypress_firmware.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/media/common/cypress_firmware.c +1 -3
index 50e3f76d4847..bfe47bc5f716 100644
@@ -78,7 +78,5 @@ int cypress_load_firmware(struct usb_device *udev,
-	if (!hx) {
-		dev_err(&udev->dev, "%s: kmalloc() failed\n", KBUILD_MODNAME);
+	if (!hx)
 		return -ENOMEM;
-	}
 
 	/* stop the CPU */
 	hx->data[0] = 1;
Signature · 1 line
2.14.1
#2 lore raw

PATCH 2/2 Cypress: Improve a size determination in cypress_load_firmware()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 28 Aug 2017 11:55:16 +0200

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

This issue was detected by using the Coccinelle software.

---
 drivers/media/common/cypress_firmware.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/common/cypress_firmware.c +1 -1
index bfe47bc5f716..8895158c1962 100644
@@ -74,7 +74,7 @@ int cypress_load_firmware(struct usb_device *udev,
 	struct hexline *hx;
 	int ret, pos = 0;
 
-	hx = kmalloc(sizeof(struct hexline), GFP_KERNEL);
+	hx = kmalloc(sizeof(*hx), GFP_KERNEL);
 	if (!hx)
 		return -ENOMEM;
 
Signature · 1 line
2.14.1