All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] firewire: fix minor issues
@ 2022-05-12 11:17 Takashi Sakamoto
  2022-05-12 11:17 ` [PATCH 1/3] firewire: convert sysfs sprintf/snprintf family to sysfs_emit Takashi Sakamoto
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2022-05-12 11:17 UTC (permalink / raw)
  To: tiwai, stefanr; +Cc: alsa-devel, linux1394-devel

Hi,

This patchset includes below patches posted by several developers.

* [PATCH v2] firewire: convert sysfs sprintf/snprintf family to sysfs_emit
  * https://lore.kernel.org/lkml/1612424420-96871-1-git-send-email-jiapeng.chong@linux.alibaba.com/
* [PATCH V2] drivers/firewire: use struct_size over open coded arithmetic
  * https://lore.kernel.org/lkml/20220210060805.1608198-1-chi.minghao@zte.com.cn/
* [PATCH] firewire: Fix using uninitialized value
  * https://lore.kernel.org/lkml/20220411105205.2520784-1-lv.ruyi@zte.com.cn/

They are for some minor issues, while preferable. I expect the patches
are going to be sent to Linus for next merge window by maintainer of either
Linux FireWire subsystem or sound subsystem.


Regards

Jiapeng Chong (1):
  firewire: convert sysfs sprintf/snprintf family to sysfs_emit

Lv Ruyi (1):
  firewire: Fix using uninitialized value

Minghao Chi (CGEL ZTE) (1):
  firewire: use struct_size over open coded arithmetic

 drivers/firewire/core-device.c      | 6 ++----
 drivers/firewire/core-transaction.c | 2 +-
 2 files changed, 3 insertions(+), 5 deletions(-)

-- 
2.34.1


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

* [PATCH 1/3] firewire: convert sysfs sprintf/snprintf family to sysfs_emit
  2022-05-12 11:17 [PATCH 0/3] firewire: fix minor issues Takashi Sakamoto
@ 2022-05-12 11:17 ` Takashi Sakamoto
  2022-05-12 11:17 ` [PATCH 2/3] firewire: use struct_size over open coded arithmetic Takashi Sakamoto
  2022-05-12 11:17 ` [PATCH 3/3] firewire: Fix using uninitialized value Takashi Sakamoto
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2022-05-12 11:17 UTC (permalink / raw)
  To: tiwai, stefanr; +Cc: Jiapeng Chong, alsa-devel, linux1394-devel, Abaci Robot

From: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>

Fix the following coccicheck warning:

./drivers/firewire/core-device.c:375:8-16: WARNING: use scnprintf or
sprintf.

Reported-by: Abaci Robot<abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 drivers/firewire/core-device.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
index 90ed8fdaba75..adddd8c45d0c 100644
--- a/drivers/firewire/core-device.c
+++ b/drivers/firewire/core-device.c
@@ -372,8 +372,7 @@ static ssize_t rom_index_show(struct device *dev,
 	struct fw_device *device = fw_device(dev->parent);
 	struct fw_unit *unit = fw_unit(dev);
 
-	return snprintf(buf, PAGE_SIZE, "%d\n",
-			(int)(unit->directory - device->config_rom));
+	return sysfs_emit(buf, "%td\n", unit->directory - device->config_rom);
 }
 
 static struct device_attribute fw_unit_attributes[] = {
@@ -403,8 +402,7 @@ static ssize_t guid_show(struct device *dev,
 	int ret;
 
 	down_read(&fw_device_rwsem);
-	ret = snprintf(buf, PAGE_SIZE, "0x%08x%08x\n",
-		       device->config_rom[3], device->config_rom[4]);
+	ret = sysfs_emit(buf, "0x%08x%08x\n", device->config_rom[3], device->config_rom[4]);
 	up_read(&fw_device_rwsem);
 
 	return ret;
-- 
2.34.1


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

* [PATCH 2/3] firewire: use struct_size over open coded arithmetic
  2022-05-12 11:17 [PATCH 0/3] firewire: fix minor issues Takashi Sakamoto
  2022-05-12 11:17 ` [PATCH 1/3] firewire: convert sysfs sprintf/snprintf family to sysfs_emit Takashi Sakamoto
@ 2022-05-12 11:17 ` Takashi Sakamoto
  2022-05-12 11:17 ` [PATCH 3/3] firewire: Fix using uninitialized value Takashi Sakamoto
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2022-05-12 11:17 UTC (permalink / raw)
  To: tiwai, stefanr; +Cc: alsa-devel, linux1394-devel, Minghao Chi (CGEL ZTE)

From: "Minghao Chi (CGEL ZTE)" <chi.minghao@zte.com.cn>

Replace zero-length array with flexible-array member and make use
of the struct_size() helper in kmalloc(). For example:

struct fw_request {
    ...
    u32 data[];
}

Make use of the struct_size() helper instead of an open-coded version
in order to avoid any potential type mistakes.

Signed-off-by: Minghao Chi (CGEL ZTE) <chi.minghao@zte.com.cn>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 drivers/firewire/core-transaction.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index e12a0a4c33f7..49657a793e80 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -778,7 +778,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
 		return NULL;
 	}
 
-	request = kmalloc(sizeof(*request) + length, GFP_ATOMIC);
+	request = kmalloc(struct_size(request, data, length), GFP_ATOMIC);
 	if (request == NULL)
 		return NULL;
 
-- 
2.34.1


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

* [PATCH 3/3] firewire: Fix using uninitialized value
  2022-05-12 11:17 [PATCH 0/3] firewire: fix minor issues Takashi Sakamoto
  2022-05-12 11:17 ` [PATCH 1/3] firewire: convert sysfs sprintf/snprintf family to sysfs_emit Takashi Sakamoto
  2022-05-12 11:17 ` [PATCH 2/3] firewire: use struct_size over open coded arithmetic Takashi Sakamoto
@ 2022-05-12 11:17 ` Takashi Sakamoto
  2 siblings, 0 replies; 4+ messages in thread
From: Takashi Sakamoto @ 2022-05-12 11:17 UTC (permalink / raw)
  To: tiwai, stefanr; +Cc: alsa-devel, linux1394-devel, Lv Ruyi, Zeal Robot

From: Lv Ruyi <lv.ruyi@zte.com.cn>

If data is null, request->data wouldn't be assigned value. It is random
value, but we use it in handle_exclusive_region_request() and
handle_fcp_region_request() later. Fix the bug by initializing it.

(Revised by Takashi Sakamoto to rebase to the previous patch.)

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
---
 drivers/firewire/core-transaction.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
index 49657a793e80..d10d890d7d48 100644
--- a/drivers/firewire/core-transaction.c
+++ b/drivers/firewire/core-transaction.c
@@ -778,7 +778,7 @@ static struct fw_request *allocate_request(struct fw_card *card,
 		return NULL;
 	}
 
-	request = kmalloc(struct_size(request, data, length), GFP_ATOMIC);
+	request = kzalloc(struct_size(request, data, length), GFP_ATOMIC);
 	if (request == NULL)
 		return NULL;
 
-- 
2.34.1


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

end of thread, other threads:[~2022-05-12 11:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-12 11:17 [PATCH 0/3] firewire: fix minor issues Takashi Sakamoto
2022-05-12 11:17 ` [PATCH 1/3] firewire: convert sysfs sprintf/snprintf family to sysfs_emit Takashi Sakamoto
2022-05-12 11:17 ` [PATCH 2/3] firewire: use struct_size over open coded arithmetic Takashi Sakamoto
2022-05-12 11:17 ` [PATCH 3/3] firewire: Fix using uninitialized value Takashi Sakamoto

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.