linux/drivers/base
Luis Chamberlain 3b9d8d3e4a firmware_loader: fix pre-allocated buf built-in firmware use
[ Upstream commit f7a07f7b96033df7709042ff38e998720a3f7119 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-26 10:47:15 +01:00
..
firmware_loader firmware_loader: fix pre-allocated buf built-in firmware use 2021-11-26 10:47:15 +01:00
power PM: base: power: don't try to use non-existing RTC for storing data 2021-09-22 12:26:39 +02:00
regmap regmap: Fix possible double-free in regcache_rbtree_exit() 2021-11-02 19:46:13 +01:00
test
Kconfig
Makefile
arch_topology.c
attribute_container.c
base.h
bus.c
cacheinfo.c
class.c
component.c
container.c
core.c PCI/MSI: Protect msi_desc::masked for multi-MSI 2021-08-18 08:57:03 +02:00
cpu.c
dd.c driver core: Fix locking bug in deferred_probe_timeout_work_func() 2021-04-16 11:46:38 +02:00
devcon.c
devcoredump.c
devres.c
devtmpfs.c
driver.c
firmware.c
hypervisor.c
init.c
isa.c
map.c
memory.c
module.c
node.c node: fix device cleanups in error handling code 2021-05-14 09:44:22 +02:00
pinctrl.c
platform-msi.c
platform.c
property.c
soc.c
swnode.c software node: Fix node registration 2021-03-17 17:03:48 +01:00
syscore.c
topology.c
transport_class.c