linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH 0/1] mcb: error for not supported devices.
@ 2023-10-19 14:15 Sanjuán García, Jorge
  2023-10-19 14:15 ` [RESEND PATCH 1/1] mcb: fix error handling for different scenarios when parsing Sanjuán García, Jorge
  0 siblings, 1 reply; 3+ messages in thread
From: Sanjuán García, Jorge @ 2023-10-19 14:15 UTC (permalink / raw)
  To: morbidrsa
  Cc: linux-kernel, gregkh, jth, Rodríguez Barbarin,
	José Javier, yangyingliang, Sanjuán García, Jorge

This patch fixes an issue where, if a MEN Chameleon device is not
supported, the early exit in chameleon_parse_gdd() will end up
calling put_device() when no device has been initialized yet. Because
the MCB subsystem does not support all the possible chameleon devices
listed for one FPGA, dmesg gets a few of these when parsing a Chameleon
FPGA:

[   32.974385] No BAR for 16z024
[   32.974386] ------------[ cut here ]------------
[   32.974388] kobject: '(null)' (000000002644a89d): is not initialized, yet kobject_put() is being called.
[   32.974403] WARNING: CPU: 0 PID: 103 at lib/kobject.c:726 kobject_put+0x52/0xa0
[   32.974410] Modules linked in: mcb_pci(+) intel_cstate mcb acpi_pad mac_hid mxm_wmi sch_fq_codel ipmi_devintf ipmi_msghandler msr parport_pc ppdev lp parport pstore_blk drm ramoops pstore_zone efi_pstore reed_solomon ip_tables x_tables autofs4 uas usb_storage spi_intel_platform spi_intel gpio_ich ixgbe igb i2c_i801 xhci_pci i2c_algo_bit xfrm_algo crc32_pclmul e1000e i2c_smbus lpc_ich xhci_pci_renesas dca mdio wmi
[   32.974455] CPU: 0 PID: 103 Comm: kworker/0:3 Tainted: G        W          6.2.0-32-generic #32~22.04.1-Ubuntu
[   32.974458] Hardware name: MEN Mikro Elektronik GmbH G25A/n/a, BIOS 1.01 01/31/2017
[   32.974460] Workqueue: events work_for_cpu_fn
[   32.974467] RIP: 0010:kobject_put+0x52/0xa0
[   32.974472] Code: 74 39 85 c0 7e 4f 4c 8b 65 f8 c9 31 c0 31 d2 31 f6 31 ff c3 cc cc cc cc 48 8b 37 48 89 fa 48 c7 c7 48 69 65 98 e8 2e ae 0e ff <0f> 0b eb be 31 c0 31 d2 31 f6 31 ff c3 cc cc cc cc 4c 89 e7 e8 05
[   32.974475] RSP: 0000:ffff9a0600597d48 EFLAGS: 00010246
[   32.974478] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000
[   32.974480] RDX: 0000000000000000 RSI: 0000000000000000 RDI: 0000000000000000
[   32.974481] RBP: ffff9a0600597d50 R08: 0000000000000000 R09: 0000000000000000
[   32.974483] R10: 0000000000000000 R11: 0000000000000000 R12: ffff8bab960c3800
[   32.974486] R13: 0000000000000000 R14: 0000000000004000 R15: ffff8bab95895c00
[   32.974488] FS:  0000000000000000(0000) GS:ffff8bb2dfc00000(0000) knlGS:0000000000000000
[   32.974491] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[   32.974493] CR2: 00007f7e688fdf3e CR3: 000000011007c003 CR4: 00000000003706f0
[   32.974496] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[   32.974498] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[   32.974500] Call Trace:
[   32.974501]  <TASK>
[   32.974503]  ? show_regs+0x72/0x90
[   32.974507]  ? kobject_put+0x52/0xa0
[   32.974512]  ? __warn+0x8d/0x160
[   32.974518]  ? kobject_put+0x52/0xa0
[   32.974523]  ? report_bug+0x1bb/0x1d0
[   32.974530]  ? handle_bug+0x46/0x90
[   32.974536]  ? exc_invalid_op+0x19/0x80
[   32.974542]  ? asm_exc_invalid_op+0x1b/0x20
[   32.974547]  ? kobject_put+0x52/0xa0
[   32.974552]  ? kobject_put+0x52/0xa0
[   32.974557]  put_device+0x13/0x30
[   32.974563]  chameleon_parse_gdd+0x149/0x1d0 [mcb]
[   32.974573]  ? chameleon_get_bar+0xc2/0xf0 [mcb]
[   32.974583]  chameleon_parse_cells+0x196/0x1c4 [mcb]
[   32.974593]  mcb_pci_probe+0xf5/0x280 [mcb_pci]
[   32.974602]  local_pci_probe+0x4b/0xb0
[   32.974607]  work_for_cpu_fn+0x1a/0x30
[   32.974613]  process_one_work+0x21f/0x440
[   32.974618]  worker_thread+0x200/0x3f0
[   32.974623]  ? __pfx_worker_thread+0x10/0x10
[   32.974627]  kthread+0xee/0x120
[   32.974633]  ? __pfx_kthread+0x10/0x10
[   32.974639]  ret_from_fork+0x2c/0x50
[   32.974644]  </TASK>
[   32.974646] ---[ end trace 0000000000000000 ]---

This error was introduced in commit: 
   commit 728ac3389296 ("mcb: mcb-parse: fix error handing in chameleon_parse_gdd()")

Jorge Sanjuan Garcia (1):
  mcb: fix error handling for different scenarios when parsing

 drivers/mcb/mcb-core.c  | 1 +
 drivers/mcb/mcb-parse.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

-- 
2.34.1

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

* [RESEND PATCH 1/1] mcb: fix error handling for different scenarios when parsing
  2023-10-19 14:15 [RESEND PATCH 0/1] mcb: error for not supported devices Sanjuán García, Jorge
@ 2023-10-19 14:15 ` Sanjuán García, Jorge
  2023-10-19 18:34   ` gregkh
  0 siblings, 1 reply; 3+ messages in thread
From: Sanjuán García, Jorge @ 2023-10-19 14:15 UTC (permalink / raw)
  To: morbidrsa
  Cc: linux-kernel, gregkh, jth, Rodríguez Barbarin,
	José Javier, yangyingliang, Sanjuán García, Jorge

chameleon_parse_gdd() may fail for different reasons and end up
in the err tag. Make sure we at least always free the mcb_device
allocated with mcb_alloc_dev().

If mcb_device_register() fails, make sure to give up the reference
in the same place the device was added.

Fixes: 728ac3389296 ("mcb: mcb-parse: fix error handing in chameleon_parse_gdd()")
Reviewed-by: Jose Javier Rodriguez Barbarin <JoseJavier.Rodriguez@duagon.com>
Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
---
 drivers/mcb/mcb-core.c  | 1 +
 drivers/mcb/mcb-parse.c | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
index 2f23b9c3b751..f797d078978f 100644
--- a/drivers/mcb/mcb-core.c
+++ b/drivers/mcb/mcb-core.c
@@ -247,6 +247,7 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
 	return 0;
 
 out:
+	put_device(&dev->dev);
 
 	return ret;
 }
diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
index 656b6b71c768..1ae37e693de0 100644
--- a/drivers/mcb/mcb-parse.c
+++ b/drivers/mcb/mcb-parse.c
@@ -106,7 +106,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
 	return 0;
 
 err:
-	put_device(&mdev->dev);
+	mcb_free_dev(mdev);
 
 	return ret;
 }
-- 
2.34.1

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

* Re: [RESEND PATCH 1/1] mcb: fix error handling for different scenarios when parsing
  2023-10-19 14:15 ` [RESEND PATCH 1/1] mcb: fix error handling for different scenarios when parsing Sanjuán García, Jorge
@ 2023-10-19 18:34   ` gregkh
  0 siblings, 0 replies; 3+ messages in thread
From: gregkh @ 2023-10-19 18:34 UTC (permalink / raw)
  To: Sanjuán García, Jorge
  Cc: morbidrsa, linux-kernel, jth, Rodríguez Barbarin,
	José Javier, yangyingliang

On Thu, Oct 19, 2023 at 02:15:34PM +0000, Sanjuán García, Jorge wrote:
> chameleon_parse_gdd() may fail for different reasons and end up
> in the err tag. Make sure we at least always free the mcb_device
> allocated with mcb_alloc_dev().
> 
> If mcb_device_register() fails, make sure to give up the reference
> in the same place the device was added.
> 
> Fixes: 728ac3389296 ("mcb: mcb-parse: fix error handing in chameleon_parse_gdd()")
> Reviewed-by: Jose Javier Rodriguez Barbarin <JoseJavier.Rodriguez@duagon.com>
> Signed-off-by: Jorge Sanjuan Garcia <jorge.sanjuangarcia@duagon.com>
> ---
>  drivers/mcb/mcb-core.c  | 1 +
>  drivers/mcb/mcb-parse.c | 2 +-
>  2 files changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mcb/mcb-core.c b/drivers/mcb/mcb-core.c
> index 2f23b9c3b751..f797d078978f 100644
> --- a/drivers/mcb/mcb-core.c
> +++ b/drivers/mcb/mcb-core.c
> @@ -247,6 +247,7 @@ int mcb_device_register(struct mcb_bus *bus, struct mcb_device *dev)
>  	return 0;
>  
>  out:
> +	put_device(&dev->dev);
>  
>  	return ret;
>  }
> diff --git a/drivers/mcb/mcb-parse.c b/drivers/mcb/mcb-parse.c
> index 656b6b71c768..1ae37e693de0 100644
> --- a/drivers/mcb/mcb-parse.c
> +++ b/drivers/mcb/mcb-parse.c
> @@ -106,7 +106,7 @@ static int chameleon_parse_gdd(struct mcb_bus *bus,
>  	return 0;
>  
>  err:
> -	put_device(&mdev->dev);
> +	mcb_free_dev(mdev);
>  
>  	return ret;
>  }
> -- 
> 2.34.1


Hi,

This is the friendly patch-bot of Greg Kroah-Hartman.  You have sent him
a patch that has triggered this response.  He used to manually respond
to these common problems, but in order to save his sanity (he kept
writing the same thing over and over, yet to different people), I was
created.  Hopefully you will not take offence and will fix the problem
in your patch and resubmit it so that it can be accepted into the Linux
kernel tree.

You are receiving this message because of the following common error(s)
as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an
  older released kernel, yet you do not have a cc: stable line in the
  signed-off-by area at all, which means that the patch will not be
  applied to any older kernel releases.  To properly fix this, please
  follow the documented rules in the
  Documentation/process/stable-kernel-rules.rst file for how to resolve
  this.

If you wish to discuss this problem further, or you have questions about
how to resolve this issue, please feel free to respond to this email and
Greg will reply once he has dug out from the pending patches received
from other developers.

thanks,

greg k-h's patch email bot

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

end of thread, other threads:[~2023-10-19 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-19 14:15 [RESEND PATCH 0/1] mcb: error for not supported devices Sanjuán García, Jorge
2023-10-19 14:15 ` [RESEND PATCH 1/1] mcb: fix error handling for different scenarios when parsing Sanjuán García, Jorge
2023-10-19 18:34   ` gregkh

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).