linux/drivers/base
Luis Chamberlain f7a07f7b96 firmware_loader: fix pre-allocated buf built-in firmware use
The firmware_loader can be used with a pre-allocated buffer
through the use of the API calls:

  o request_firmware_into_buf()
  o request_partial_firmware_into_buf()

If the firmware was built-in and present, our current check
for if the built-in firmware fits into the pre-allocated buffer
does not return any errors, and we proceed to tell the caller
that everything worked fine. It's a lie and no firmware would
end up being copied into the pre-allocated buffer. So if the
caller trust the result it may end up writing a bunch of 0's
to a device!

Fix this by making the function that checks for the pre-allocated
buffer return non-void. Since the typical use case is when no
pre-allocated buffer is provided make this return successfully
for that case. If the built-in firmware does *not* fit into the
pre-allocated buffer size return a failure as we should have
been doing before.

I'm not aware of users of the built-in firmware using the API
calls with a pre-allocated buffer, as such I doubt this fixes
any real life issue. But you never know... perhaps some oddball
private tree might use it.

In so far as upstream is concerned this just fixes our code for
correctness.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20210917182226.3532898-2-mcgrof@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-10-05 16:26:29 +02:00
..
firmware_loader firmware_loader: fix pre-allocated buf built-in firmware use 2021-10-05 16:26:29 +02:00
power xen: branch for v5.15-rc2 2021-09-17 08:31:49 -07:00
regmap Merge series "Use raw spinlocks in the ls-extirq driver" from Vladimir Oltean <vladimir.oltean@nxp.com>: 2021-08-26 13:40:35 +01:00
test device property: Remove some casts in property-entry-test 2021-06-23 16:37:21 -06:00
arch_numa.c memblock: introduce saner 'memblock_free_ptr()' interface 2021-09-14 13:23:22 -07:00
arch_topology.c drivers/base/arch_topology.c: remove superfluous header 2021-10-05 16:21:01 +02:00
attribute_container.c driver core: attribute_container: fix W=1 warnings 2021-05-14 13:37:10 +02:00
auxiliary.c Merge 5.14-rc3 into driver-core-next 2021-07-27 09:22:08 +02:00
base.h software nodes: Split software_node_notify() 2021-07-16 19:17:05 +02:00
bus.c driver: base: Replace symbolic permissions with octal permissions 2021-07-21 14:56:00 +02:00
cacheinfo.c cacheinfo: clear cache_leaves(cpu) in free_cache_attributes() 2021-07-21 17:29:40 +02:00
class.c drivers: base: fix some kernel-doc markups 2020-11-09 18:56:49 +01:00
component.c drivers/base/component.c: remove superfluous header files from component.c 2021-10-05 16:21:10 +02:00
container.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
core.c driver core: use NUMA_NO_NODE during device_initialize 2021-10-05 15:42:22 +02:00
cpu.c driver: base: Prefer unsigned int to bare use of unsigned 2021-07-21 17:30:09 +02:00
dd.c Merge 5.14-rc5 into driver-core-next 2021-08-09 09:03:47 +02:00
devcoredump.c devcoredump: remove contact information 2021-06-04 15:05:44 +02:00
devres.c devres: Enable trace events 2021-06-15 17:14:36 +02:00
devtmpfs.c devtmpfs: actually reclaim some init memory 2021-03-23 14:57:35 +01:00
driver.c drivers: base: Convert to printk alias functions 2020-07-10 14:16:44 +02:00
firmware.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
hypervisor.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
init.c driver core: auxiliary bus: Fix calling stage for auxiliary bus init 2021-02-11 08:43:03 +01:00
isa.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
Kconfig RISC-V Patches for the 5.12 Merge Window 2021-02-26 10:28:35 -08:00
Makefile devres: Enable trace events 2021-06-15 17:14:36 +02:00
map.c driver: base: Prefer unsigned int to bare use of unsigned 2021-07-21 17:30:09 +02:00
memory.c Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
module.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
node.c Merge branch 'akpm' (patches from Andrew) 2021-09-08 12:55:35 -07:00
pinctrl.c driver core: Remove redundant license text 2017-12-07 18:36:44 +01:00
platform-msi.c platform-msi: Add ABI to show msi_irqs of platform devices 2021-08-24 09:16:20 +02:00
platform.c driver core: platform: Make use of the helper macro SET_RUNTIME_PM_OPS() 2021-09-14 16:52:41 +02:00
property.c Revert "media: device property: Call fwnode_graph_get_endpoint_by_id() for fwnode->secondary" 2021-08-16 18:35:42 +02:00
soc.c soc: fix comment for freeing soc_dev_attr 2020-12-09 19:46:31 +01:00
swnode.c software node: balance refcount for managed software nodes 2021-09-16 13:13:48 +02:00
syscore.c syscore: Use pm_pr_dbg() for syscore_{suspend,resume}() 2020-09-08 13:32:06 +02:00
topology.c topology: use bin_attribute to break the size limitation of cpumap ABI 2021-08-13 10:27:49 +02:00
trace.c devres: Enable trace events 2021-06-15 17:14:36 +02:00
trace.h devres: Enable trace events 2021-06-15 17:14:36 +02:00
transport_class.c scsi: drivers: base: Propagate errors through the transport component 2020-01-15 22:55:37 -05:00