Skip to contentSkip to conversation

scsi: leapraid: avoid -Wformat-security warning

PATCH Applied Arnd Bergmann 3 participants 3 messages Sep 15 – Sep 17

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

PATCH 1/1 scsi: leapraid: avoid -Wformat-security warning

From: Arnd Bergmann <[email protected]>

When extra warnings are enabled, the alloc_ordered_workqueue() function cannot be called with a variable name for the format string:

drivers/scsi/leapraid/leapraid_os.c: In function 'leapraid_probe':
drivers/scsi/leapraid/leapraid_os.c:2062:58: error: format not a string literal and no format arguments [-Werror=format-security]

 2062 |                 alloc_ordered_workqueue(adapter->fw_evt_s.fw_evt_name, 0);
      |                                         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

As the string is only assembled before the call and not used anywhere else, just fold the earlier snprintf() into the alloc_ordered_workqueue() call.

Fixes 5597088c9e79 ("scsi: leapraid: Add new SCSI driver")
---
 drivers/scsi/leapraid/leapraid_func.h | 2 --
 drivers/scsi/leapraid/leapraid_os.c   | 8 +++-----
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/scsi/leapraid/leapraid_func.h +0 -2
index 4c0b9ca728d8..e8a0815bf95f 100644
@@ -554,7 +554,6 @@ struct leapraid_fw_evt_work {
 /**
  * struct leapraid_fw_evt_struct - Firmware event handling structure
  *
- * @fw_evt_name: Name of the firmware event.
  * @fw_evt_thread: Workqueue used for processing firmware events.
  * @fw_evt_lock: Spinlock protecting access to the firmware event list.
  * @fw_evt_list: Linked list of pending firmware events.
@@ -565,7 +564,6 @@ struct leapraid_fw_evt_work {
  */
 struct leapraid_fw_evt_struct {
 	u32 leapraid_evt_masks[4];
-	char fw_evt_name[48];
 	struct workqueue_struct *fw_evt_thread;
 	spinlock_t fw_evt_lock; /* protects firmware event */
 	struct list_head fw_evt_list;
drivers/scsi/leapraid/leapraid_os.c +3 -5
index ee3242779dfd..507f11862276 100644
@@ -2054,12 +2054,10 @@ static int leapraid_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	shost->transportt = leapraid_transport_template;
 	shost->unique_id = adapter->adapter_attr.id;
 
-	snprintf(adapter->fw_evt_s.fw_evt_name,
-		 sizeof(adapter->fw_evt_s.fw_evt_name),
-		 "fw_event_%s%d", LEAPRAID_DRIVER_NAME,
-		 adapter->adapter_attr.id);
 	adapter->fw_evt_s.fw_evt_thread =
-		alloc_ordered_workqueue(adapter->fw_evt_s.fw_evt_name, 0);
+		alloc_ordered_workqueue("fw_event_%s%d", 0,
+					LEAPRAID_DRIVER_NAME,
+					adapter->adapter_attr.id);
 	if (!adapter->fw_evt_s.fw_evt_thread) {
 		dev_err(&adapter->pdev->dev,
 			"%s: Failed to create fw event workqueue\n", __func__);
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Arnd Bergmann

From: Arnd Bergmann <[email protected]>

When extra warnings are enabled, the alloc_ordered_workqueue() function cannot be called with a variable name for the format string:

drivers/scsi/leapraid/leapraid_os.c: In function 'leapraid_probe':
drivers/scsi/leapraid/leapraid_os.c:2062:58: error: format not a string literal and no format arguments [-Werror=format-security]

 2062 |                 alloc_ordered_workqueue(adapter->fw_evt_s.fw_evt_name, 0);
      |                                         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
Quoted 6 lines

As the string is only assembled before the call and not used anywhere else, just fold the earlier snprintf() into the alloc_ordered_workqueue() call.

Fixes 5597088c9e79 ("scsi: leapraid: Add new SCSI driver")
Signature · 2 lines
Damien Le Moal
Western Digital Research
maintainer Applied
#2 lore raw
In reply to Arnd Bergmann
Quoted 9 lines · Arnd Bergmann

When extra warnings are enabled, the alloc_ordered_workqueue() function cannot be called with a variable name for the format string:

drivers/scsi/leapraid/leapraid_os.c: In function 'leapraid_probe':
drivers/scsi/leapraid/leapraid_os.c:2062:58: error: format not a string literal and no format arguments [-Werror=format-security]

 2062 |                 alloc_ordered_workqueue(adapter->fw_evt_s.fw_evt_name, 0);
      |                                         ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

[...]

Applied to 7.3/scsi-fixes, thanks!

[1/1] scsi: leapraid: avoid -Wformat-security warning

      https://git.kernel.org/mkp/scsi/c/278210c60c6f
Signature · 1 line
Martin K. Petersen