kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] firewire: nosy: Fix the amount of memory deallocated by some 'pci_free_consistent' calls
@ 2020-06-24 19:23 Christophe JAILLET
  2020-06-24 22:35 ` kernel test robot
  2020-06-25 19:15 ` [PATCH V2] " Christophe JAILLET
  0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2020-06-24 19:23 UTC (permalink / raw)
  To: stefanr, krh, hch
  Cc: linux1394-devel, linux-kernel, kernel-janitors, Christophe JAILLET

'lynx->pci_device' is allocated with a size of RCV_BUFFER_SIZE. This is to
say (16 * 1024).

Pass the same size when it is freed.

Fixes: 286468210d83 ("firewire: new driver: nosy - IEEE 1394 traffic sniffer")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/firewire/nosy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 5fd6a60b6741..445c37f5251d 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -510,7 +510,7 @@ remove_card(struct pci_dev *dev)
 			    lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
 	pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
 			    lynx->rcv_pcl, lynx->rcv_pcl_bus);
-	pci_free_consistent(lynx->pci_device, PAGE_SIZE,
+	pci_free_consistent(lynx->pci_device, RCV_BUFFER_SIZE,
 			    lynx->rcv_buffer, lynx->rcv_buffer_bus);
 
 	iounmap(lynx->registers);
@@ -668,7 +668,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)
 		pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
 				lynx->rcv_pcl, lynx->rcv_pcl_bus);
 	if (lynx->rcv_buffer)
-		pci_free_consistent(lynx->pci_device, PAGE_SIZE,
+		pci_free_consistent(lynx->pci_device, RCV_BUFFER_SIZE,
 				lynx->rcv_buffer, lynx->rcv_buffer_bus);
 	iounmap(lynx->registers);
 
-- 
2.25.1

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

* Re: [PATCH] firewire: nosy: Fix the amount of memory deallocated by some 'pci_free_consistent' calls
  2020-06-24 19:23 [PATCH] firewire: nosy: Fix the amount of memory deallocated by some 'pci_free_consistent' calls Christophe JAILLET
@ 2020-06-24 22:35 ` kernel test robot
  2020-06-25 19:15 ` [PATCH V2] " Christophe JAILLET
  1 sibling, 0 replies; 3+ messages in thread
From: kernel test robot @ 2020-06-24 22:35 UTC (permalink / raw)
  To: Christophe JAILLET, stefanr, krh, hch
  Cc: kbuild-all, linux1394-devel, linux-kernel, kernel-janitors

[-- Attachment #1: Type: text/plain, Size: 2630 bytes --]

Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on firewire/for-next]
[also build test ERROR on v5.8-rc2 next-20200624]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Christophe-JAILLET/firewire-nosy-Fix-the-amount-of-memory-deallocated-by-some-pci_free_consistent-calls/20200625-032633
base:   https://git.kernel.org/pub/scm/linux/kernel/git/ieee1394/linux1394.git for-next
config: x86_64-randconfig-m001-20200624 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-13) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

   drivers/firewire/nosy.c: In function 'remove_card':
>> drivers/firewire/nosy.c:513:40: error: 'RCV_BUFFER_SIZE' undeclared (first use in this function); did you mean 'UEVENT_BUFFER_SIZE'?
     513 |  pci_free_consistent(lynx->pci_device, RCV_BUFFER_SIZE,
         |                                        ^~~~~~~~~~~~~~~
         |                                        UEVENT_BUFFER_SIZE
   drivers/firewire/nosy.c:513:40: note: each undeclared identifier is reported only once for each function it appears in

vim +513 drivers/firewire/nosy.c

   489	
   490	static void
   491	remove_card(struct pci_dev *dev)
   492	{
   493		struct pcilynx *lynx = pci_get_drvdata(dev);
   494		struct client *client;
   495	
   496		mutex_lock(&card_mutex);
   497		list_del_init(&lynx->link);
   498		misc_deregister(&lynx->misc);
   499		mutex_unlock(&card_mutex);
   500	
   501		reg_write(lynx, PCI_INT_ENABLE, 0);
   502		free_irq(lynx->pci_device->irq, lynx);
   503	
   504		spin_lock_irq(&lynx->client_list_lock);
   505		list_for_each_entry(client, &lynx->client_list, link)
   506			wake_up_interruptible(&client->buffer.wait);
   507		spin_unlock_irq(&lynx->client_list_lock);
   508	
   509		pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
   510				    lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
   511		pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
   512				    lynx->rcv_pcl, lynx->rcv_pcl_bus);
 > 513		pci_free_consistent(lynx->pci_device, RCV_BUFFER_SIZE,
   514				    lynx->rcv_buffer, lynx->rcv_buffer_bus);
   515	
   516		iounmap(lynx->registers);
   517		pci_disable_device(dev);
   518		lynx_put(lynx);
   519	}
   520	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 31861 bytes --]

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

* [PATCH V2] firewire: nosy: Fix the amount of memory deallocated by some 'pci_free_consistent' calls
  2020-06-24 19:23 [PATCH] firewire: nosy: Fix the amount of memory deallocated by some 'pci_free_consistent' calls Christophe JAILLET
  2020-06-24 22:35 ` kernel test robot
@ 2020-06-25 19:15 ` Christophe JAILLET
  1 sibling, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2020-06-25 19:15 UTC (permalink / raw)
  To: stefanr, krh, hch
  Cc: linux1394-devel, linux-kernel, kernel-janitors, Christophe JAILLET

'lynx->pci_device' is allocated with a size of RCV_BUFFER_SIZE. This is to
say (16 * 1024).

Pass the same size when it is freed.

Fixes: 286468210d83 ("firewire: new driver: nosy - IEEE 1394 traffic sniffer")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
v2: move the #define RCV_BUFFER_SIZE at the top of the file so that it is
    defined when used in 'remove_card()'
    Spotted by kernel test robot <lkp@intel.com>
---
 drivers/firewire/nosy.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c
index 5fd6a60b6741..2fe34a2ce7cc 100644
--- a/drivers/firewire/nosy.c
+++ b/drivers/firewire/nosy.c
@@ -36,6 +36,8 @@
 
 static char driver_name[] = KBUILD_MODNAME;
 
+#define RCV_BUFFER_SIZE (16 * 1024)
+
 /* this is the physical layout of a PCL, its size is 128 bytes */
 struct pcl {
 	__le32 next;
@@ -510,7 +512,7 @@ remove_card(struct pci_dev *dev)
 			    lynx->rcv_start_pcl, lynx->rcv_start_pcl_bus);
 	pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
 			    lynx->rcv_pcl, lynx->rcv_pcl_bus);
-	pci_free_consistent(lynx->pci_device, PAGE_SIZE,
+	pci_free_consistent(lynx->pci_device, RCV_BUFFER_SIZE,
 			    lynx->rcv_buffer, lynx->rcv_buffer_bus);
 
 	iounmap(lynx->registers);
@@ -518,8 +520,6 @@ remove_card(struct pci_dev *dev)
 	lynx_put(lynx);
 }
 
-#define RCV_BUFFER_SIZE (16 * 1024)
-
 static int
 add_card(struct pci_dev *dev, const struct pci_device_id *unused)
 {
@@ -668,7 +668,7 @@ add_card(struct pci_dev *dev, const struct pci_device_id *unused)
 		pci_free_consistent(lynx->pci_device, sizeof(struct pcl),
 				lynx->rcv_pcl, lynx->rcv_pcl_bus);
 	if (lynx->rcv_buffer)
-		pci_free_consistent(lynx->pci_device, PAGE_SIZE,
+		pci_free_consistent(lynx->pci_device, RCV_BUFFER_SIZE,
 				lynx->rcv_buffer, lynx->rcv_buffer_bus);
 	iounmap(lynx->registers);
 
-- 
2.25.1

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

end of thread, other threads:[~2020-06-25 19:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-24 19:23 [PATCH] firewire: nosy: Fix the amount of memory deallocated by some 'pci_free_consistent' calls Christophe JAILLET
2020-06-24 22:35 ` kernel test robot
2020-06-25 19:15 ` [PATCH V2] " Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).