mcb changes for 5.14
cover mcb changes for 5.14
Hi Greg,
Here are the collected patches for mcb for 5.14.
The following changes since commit 009c9aa5be652675a06d5211e1640e02bbb1c33d:
Linux 5.13-rc6 (2021-06-13 14:43:10 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/jth/linux.git mcb-for-5.14
for you to fetch changes up to fe520620eeddaa2ed8c669125f9b673c89d6b5a5:
mcb: Remove trailing semicolon in macros (2021-06-15 23:43:47 +0900)
----------------------------------------------------------------
Alternatively the broken out patches are in this thread.
Dan Carpenter (1):
mcb: fix error handling in mcb_alloc_bus()
Huilong Deng (1):
mcb: Remove trailing semicolon in macros
Zhen Lei (1):
mcb: Use DEFINE_RES_MEM() to simplify code
drivers/mcb/mcb-core.c | 12 ++++++------ drivers/mcb/mcb-lpc.c | 13 ++----------- include/linux/mcb.h | 2 +- 3 files changed, 9 insertions(+), 18 deletions(-)
Signature · 1 line
2.31.1
PATCH 1/3 mcb: Use DEFINE_RES_MEM() to simplify code
From: Zhen Lei <[email protected]>
The value of '.end' should be "start + size - 1". So the previous writing should have omitted subtracted 1.
--- drivers/mcb/mcb-lpc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)
drivers/mcb/mcb-lpc.c +2 -11
@@ -105,17 +105,8 @@ static int mcb_lpc_create_platform_device(const struct dmi_system_id *id)return ret; } -static struct resource sc24_fpga_resource = { - .start =0xe000e000 , - .end =0xe000e000 +CHAM_HEADER_SIZE , - .flags =IORESOURCE_MEM , -}; - -static struct resource sc31_fpga_resource = { - .start =0xf000e000 , - .end =0xf000e000 +CHAM_HEADER_SIZE , - .flags =IORESOURCE_MEM , -}; +static struct resource sc24_fpga_resource =DEFINE_RES_MEM (0xe000e000 ,CHAM_HEADER_SIZE ); +static struct resource sc31_fpga_resource =DEFINE_RES_MEM (0xf000e000 ,CHAM_HEADER_SIZE );static struct platform_driver mcb_lpc_driver = { .driver = {
Signature · 1 line
2.31.1
Re: [PATCH 1/3] mcb: Use DEFINE_RES_MEM() to simplify code
Quoted 22 lines · Johannes Thumshirn
From: Zhen Lei <[email protected]>
The value of '.end' should be "start + size - 1". So the previous writing should have omitted subtracted 1.
Signed-off-by Zhen Lei <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>--- drivers/mcb/mcb-lpc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)drivers/mcb/mcb-lpc.c +0
-3@@ -105,17 +105,8 @@ static int mcb_lpc_create_platform_device(const struct dmi_system_id *id)return ret; } -static struct resource sc24_fpga_resource = { - .start =0xe000e000 , - .end =0xe000e000 +CHAM_HEADER_SIZE ,
drivers/mcb/mcb-lpc.c static int mcb_lpc_create_platform_device(const struct dmi_system_id *id) · line 109
Quoted 10 lines
drivers/mcb/mcb-lpc.c +2
-8- .flags = IORESOURCE_MEM, -}; - -static struct resource sc31_fpga_resource = { - .start =0xf000e000 , - .end =0xf000e000 +CHAM_HEADER_SIZE , - .flags =IORESOURCE_MEM , -}; +static struct resource sc24_fpga_resource =DEFINE_RES_MEM (0xe000e000 ,CHAM_HEADER_SIZE ); +static struct resource sc31_fpga_resource =DEFINE_RES_MEM (0xf000e000 ,CHAM_HEADER_SIZE );
Does this simplify stuff, or does it fix a bug with the existing definition?
Your changelog text says one thing, but your subject says the other...
thanks,
greg k-h
Re: [PATCH 1/3] mcb: Use DEFINE_RES_MEM() to simplify code
Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · Johannes Thumshirn
From: Zhen Lei <[email protected]>
The value of '.end' should be "start + size - 1". So the previous writing should have omitted subtracted 1.
Signed-off-by Zhen Lei <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>--- drivers/mcb/mcb-lpc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)drivers/mcb/mcb-lpc.c +0
-0@@ -105,17 +105,8 @@ static int mcb_lpc_create_platform_device(const struct dmi_system_id *id)return ret; }
Quoted 16 lines
drivers/mcb/mcb-lpc.c static int mcb_lpc_create_platform_device(const struct dmi_system_id *id) · line 109
Quoted 13 lines
drivers/mcb/mcb-lpc.c +2
-11-static struct resource sc24_fpga_resource = { - .start =0xe000e000 , - .end =0xe000e000 +CHAM_HEADER_SIZE , - .flags =IORESOURCE_MEM , -}; - -static struct resource sc31_fpga_resource = { - .start =0xf000e000 , - .end =0xf000e000 +CHAM_HEADER_SIZE , - .flags =IORESOURCE_MEM , -}; +static struct resource sc24_fpga_resource =DEFINE_RES_MEM (0xe000e000 ,CHAM_HEADER_SIZE ); +static struct resource sc31_fpga_resource =DEFINE_RES_MEM (0xf000e000 ,CHAM_HEADER_SIZE );Does this simplify stuff, or does it fix a bug with the existing definition?
It does not fix a bug, the actual value of .end should be "0xe000e000 + CHAM_HEADER_SIZE - 1". There is no functional problem, just a little more memory. So it's just been corrected in the process of simplification.
Do you think it's necessary to split it into two patches?
Quoted 2 lines
Your changelog text says one thing, but your subject says the other...
Okay, I'll change the description. How about:
Use DEFINE_RES_MEM() to save a couple of lines of code, which makes the code a bit shorter and easier to read. The start address does not need to appear twice.
By the way, the value of '.end' should be "start + size - 1". So the previous writing should have omitted subtracted 1.
Quoted 7 lines
thanks,
greg k-h
.
Re: [PATCH 1/3] mcb: Use DEFINE_RES_MEM() to simplify code
Quoted 40 lines · Leizhen (ThunderTown)
Quoted 20 lines · Greg Kroah-Hartman
Quoted 19 lines · Johannes Thumshirn
From: Zhen Lei <[email protected]>
The value of '.end' should be "start + size - 1". So the previous writing should have omitted subtracted 1.
Signed-off-by Zhen Lei <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>--- drivers/mcb/mcb-lpc.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-)drivers/mcb/mcb-lpc.c +0
-0@@ -105,17 +105,8 @@ static int mcb_lpc_create_platform_device(const struct dmi_system_id *id)return ret; }Quoted 16 lines
drivers/mcb/mcb-lpc.c static int mcb_lpc_create_platform_device(const struct dmi_system_id *id) · line 109
Quoted 13 lines
drivers/mcb/mcb-lpc.c +2
-11-static struct resource sc24_fpga_resource = { - .start =0xe000e000 , - .end =0xe000e000 +CHAM_HEADER_SIZE , - .flags =IORESOURCE_MEM , -}; - -static struct resource sc31_fpga_resource = { - .start =0xf000e000 , - .end =0xf000e000 +CHAM_HEADER_SIZE , - .flags =IORESOURCE_MEM , -}; +static struct resource sc24_fpga_resource =DEFINE_RES_MEM (0xe000e000 ,CHAM_HEADER_SIZE ); +static struct resource sc31_fpga_resource =DEFINE_RES_MEM (0xf000e000 ,CHAM_HEADER_SIZE );Does this simplify stuff, or does it fix a bug with the existing definition?
Quoted 5 lines
It does not fix a bug, the actual value of .end should be "
0xe000e000+CHAM_HEADER_SIZE- 1". There is no functional problem, just a little more memory. So it's just been corrected in the process of simplification.Do you think it's necessary to split it into two patches?
No need, I just want to know if this is a fix that needs to go to older kernels as well. The text was very vague.
thanks,
greg k-h
PATCH 2/3 mcb: fix error handling in mcb_alloc_bus()
In reply to Johannes ThumshirnFrom: Dan Carpenter <[email protected]>
There are two bugs:
1) If ida_simple_get() fails then this code calls put_device(carrier) but we haven't yet called get_device(carrier) and probably that leads to a use after free.
2) After device_initialize() then we need to use put_device() to release the bus. This will free the internal resources tied to the device and call mcb_free_bus() which will free the rest.
--- drivers/mcb/mcb-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mcb/mcb-core.c +6 -6
@@ -277,8 +277,8 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier) bus_nr =ida_simple_get (&mcb_ida,0 ,0 ,GFP_KERNEL );if (bus_nr <0 ) { - rc = bus_nr; - goto err_free; +kfree (bus); +return ERR_PTR (bus_nr); } bus->bus_nr = bus_nr;
@@ -293,12 +293,12 @@ struct mcb_bus *mcb_alloc_bus(struct device *carrier)dev_set_name (&bus->dev,"mcb:%d" , bus_nr); rc =device_add (&bus->dev);if (rc) - goto err_free; + goto err_put;return bus; -err_free: -put_device (carrier); -kfree (bus); + +err_put: +put_device (&bus->dev);return ERR_PTR (rc); }EXPORT_SYMBOL_NS_GPL (mcb_alloc_bus,MCB );
Signature · 1 line
2.31.1
Re: [PATCH 2/3] mcb: fix error handling in mcb_alloc_bus()
Quoted 10 lines · Johannes Thumshirn
From: Dan Carpenter <[email protected]>
There are two bugs:
1) Ifida_simple_get()fails then this code callsput_device(carrier)but we haven't yet calledget_device(carrier)and probably that leads to a use after free.
2) Afterdevice_initialize()then we need to useput_device()to release the bus. This will free the internal resources tied to the device and callmcb_free_bus()which will free the rest.
Quoted 7 lines
Fixes 5d9e2ab9fea4 ("mcb: Implement bus->dev.release callback")Fixes 18d288198099 ("mcb: Correctly initialize the bus's device")Signed-off-by Dan Carpenter <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>--- drivers/mcb/mcb-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Shouldn't this go to the stable kernels? Why not cc: stable in the signed-off-by lines?
thanks,
greg k-h
Re: [PATCH 2/3] mcb: fix error handling in mcb_alloc_bus()
Quoted 19 lines · Greg Kroah-Hartman
Quoted 10 lines · Johannes Thumshirn
From: Dan Carpenter <[email protected]>
There are two bugs:
1) Ifida_simple_get()fails then this code callsput_device(carrier)but we haven't yet calledget_device(carrier)and probably that leads to a use after free.
2) Afterdevice_initialize()then we need to useput_device()to release the bus. This will free the internal resources tied to the device and callmcb_free_bus()which will free the rest.Quoted 7 lines
Fixes 5d9e2ab9fea4 ("mcb: Implement bus->dev.release callback")Fixes 18d288198099 ("mcb: Correctly initialize the bus's device")Signed-off-by Dan Carpenter <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>--- drivers/mcb/mcb-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
Quoted 2 lines
Shouldn't this go to the stable kernels? Why not cc: stable in the signed-off-by lines?
Right, I'll add a cc stable
PATCH 3/3 mcb: Remove trailing semicolon in macros
In reply to Johannes ThumshirnFrom: Huilong Deng <[email protected]>
Macros should not use a trailing semicolon.
--- include/linux/mcb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mcb.h +1 -1
@@ -120,7 +120,7 @@ extern int __must_check __mcb_register_driver(struct mcb_driver *drv, __mcb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)extern void mcb_unregister_driver (struct mcb_driver *driver);#define module_mcb_driver (__mcb_driver) \ - module_driver(__mcb_driver, mcb_register_driver, mcb_unregister_driver); + module_driver(__mcb_driver, mcb_register_driver, mcb_unregister_driver)extern void mcb_bus_add_devices (const struct mcb_bus *bus);extern int mcb_device_register (struct mcb_bus *bus,struct mcb_device *dev);extern struct mcb_bus *mcb_alloc_bus (struct device *carrier);
Signature · 1 line
2.31.1
Re: [PATCH 3/3] mcb: Remove trailing semicolon in macros
Quoted 26 lines · Johannes Thumshirn
From: Huilong Deng <[email protected]>
Macros should not use a trailing semicolon.
Signed-off-by Huilong Deng <[email protected]>Signed-off-by Johannes Thumshirn <[email protected]>--- include/linux/mcb.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/linux/mcb.h +1
-1@@ -120,7 +120,7 @@ extern int __must_check __mcb_register_driver(struct mcb_driver *drv, __mcb_register_driver(driver, THIS_MODULE, KBUILD_MODNAME)extern void mcb_unregister_driver (struct mcb_driver *driver);#define module_mcb_driver (__mcb_driver) \ - module_driver(__mcb_driver, mcb_register_driver, mcb_unregister_driver); + module_driver(__mcb_driver, mcb_register_driver, mcb_unregister_driver)extern void mcb_bus_add_devices (const struct mcb_bus *bus);extern int mcb_device_register (struct mcb_bus *bus,struct mcb_device *dev);extern struct mcb_bus *mcb_alloc_bus (struct device *carrier);Signature · 1 line
2.31.1
I've applied this one, feel free to resend the first 2 as emails.
thanks,
greg k-h