public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] greybus: es2: drop redundant device reference
@ 2026-03-05 12:50 Johan Hovold
  2026-03-06  5:30 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2026-03-05 12:50 UTC (permalink / raw)
  To: Johan Hovold, Alex Elder, Greg Kroah-Hartman; +Cc: greybus-dev, linux-kernel

Driver core holds a reference to the USB interface and its parent USB
device while the interface is bound to a driver and there is no need to
take additional references unless the structures are needed after
disconnect.

Drop the redundant device reference to reduce cargo culting, make it
easier to spot drivers where an extra reference is needed, and reduce
the risk of memory leaks when drivers fail to release it.

Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/greybus/es2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/greybus/es2.c b/drivers/greybus/es2.c
index 6ae0ac828afa..bb513ef7f7ff 100644
--- a/drivers/greybus/es2.c
+++ b/drivers/greybus/es2.c
@@ -806,8 +806,6 @@ static void es2_destroy(struct es2_ap_dev *es2)
 
 	udev = es2->usb_dev;
 	gb_hd_put(es2->hd);
-
-	usb_put_dev(udev);
 }
 
 static void cport_in_callback(struct urb *urb)
@@ -1257,7 +1255,7 @@ static int ap_probe(struct usb_interface *interface,
 	bool bulk_in_found = false;
 	bool arpc_in_found = false;
 
-	udev = usb_get_dev(interface_to_usbdev(interface));
+	udev = interface_to_usbdev(interface);
 
 	num_cports = apb_get_cport_count(udev);
 	if (num_cports < 0) {
-- 
2.52.0


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

* Re: [PATCH] greybus: es2: drop redundant device reference
  2026-03-05 12:50 [PATCH] greybus: es2: drop redundant device reference Johan Hovold
@ 2026-03-06  5:30 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2026-03-06  5:30 UTC (permalink / raw)
  To: Johan Hovold, Alex Elder, Greg Kroah-Hartman
  Cc: oe-kbuild-all, greybus-dev, linux-kernel

Hi Johan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linus/master]
[also build test WARNING on v7.0-rc2 next-20260305]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Johan-Hovold/greybus-es2-drop-redundant-device-reference/20260305-210146
base:   linus/master
patch link:    https://lore.kernel.org/r/20260305125036.10856-1-johan%40kernel.org
patch subject: [PATCH] greybus: es2: drop redundant device reference
config: i386-buildonly-randconfig-001-20260306 (https://download.01.org/0day-ci/archive/20260306/202603061306.GsnCxitD-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260306/202603061306.GsnCxitD-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202603061306.GsnCxitD-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/greybus/es2.c: In function 'es2_destroy':
>> drivers/greybus/es2.c:775:28: warning: variable 'udev' set but not used [-Wunused-but-set-variable]
     775 |         struct usb_device *udev;
         |                            ^~~~


vim +/udev +775 drivers/greybus/es2.c

f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  772  
57bc17ffc566de drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  773  static void es2_destroy(struct es2_ap_dev *es2)
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  774  {
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21 @775  	struct usb_device *udev;
1521eb6b6995dd drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  776  	struct urb *urb;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  777  	int i;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  778  
74cd6503e5d4f0 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  779  	debugfs_remove(es2->apb_log_enable_dentry);
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  780  	usb_log_disable(es2);
ca3ec299c2d090 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2015-03-27  781  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  782  	/* Tear down everything! */
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  783  	for (i = 0; i < NUM_CPORT_OUT_URB; ++i) {
1521eb6b6995dd drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  784  		urb = es2->cport_out_urb[i];
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  785  		usb_kill_urb(urb);
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  786  		usb_free_urb(urb);
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  787  		es2->cport_out_urb[i] = NULL;
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  788  		es2->cport_out_urb_busy[i] = false;	/* just to be anal */
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  789  	}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  790  
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  791  	for (i = 0; i < NUM_ARPC_IN_URB; ++i) {
1521eb6b6995dd drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  792  		usb_free_urb(es2->arpc_urb[i]);
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  793  		kfree(es2->arpc_buffer[i]);
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  794  		es2->arpc_buffer[i] = NULL;
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  795  	}
9d9d3777a9db5c drivers/staging/greybus/es2.c    Alexandre Bailon   2016-07-07  796  
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  797  	for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  798  		usb_free_urb(es2->cport_in.urb[i]);
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  799  		kfree(es2->cport_in.buffer[i]);
7330c48ec09367 drivers/staging/greybus/es2.c    Greg Kroah-Hartman 2016-08-17  800  		es2->cport_in.buffer[i] = NULL;
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  801  	}
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  802  
52033fdebc9202 drivers/staging/greybus/es2.c    Vaibhav Agarwal    2016-05-27  803  	/* release reserved CDSI0 and CDSI1 cports */
52033fdebc9202 drivers/staging/greybus/es2.c    Vaibhav Agarwal    2016-05-27  804  	gb_hd_cport_release_reserved(es2->hd, ES2_CPORT_CDSI1);
52033fdebc9202 drivers/staging/greybus/es2.c    Vaibhav Agarwal    2016-05-27  805  	gb_hd_cport_release_reserved(es2->hd, ES2_CPORT_CDSI0);
52033fdebc9202 drivers/staging/greybus/es2.c    Vaibhav Agarwal    2016-05-27  806  
4b1d82047ebbb1 drivers/staging/greybus/es2.c    Alex Elder         2015-10-27  807  	udev = es2->usb_dev;
c1700479845bc3 drivers/staging/greybus/es2.c    Johan Hovold       2015-11-04  808  	gb_hd_put(es2->hd);
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  809  }
f587027e793cf8 drivers/staging/greybus/gb-es2.c Greg Kroah-Hartman 2015-01-21  810  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

end of thread, other threads:[~2026-03-06  5:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 12:50 [PATCH] greybus: es2: drop redundant device reference Johan Hovold
2026-03-06  5:30 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox