Commit d28912d6 authored by Arnd Bergmann's avatar Arnd Bergmann

Merge tag 'arm-ffa-fixes-5.14' of...

Merge tag 'arm-ffa-fixes-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/fixes

Arm FF-A fixes for v5.14

A small set of fixes:
- adding check for presence of probe while registering the driver to
  prevent NULL pointer access
- dropping the duplicate check as the driver core already takes care of it
- fixing possible ffa_linux_errmap buffer overflow and
- fixing kernel-doc warning for comment style

* tag 'arm-ffa-fixes-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux:
  firmware: arm_ffa: Fix a possible ffa_linux_errmap buffer overflow
  firmware: arm_ffa: Fix the comment style
  firmware: arm_ffa: Simplify probe function
  firmware: arm_ffa: Ensure drivers provide a probe function

Link: https://lore.kernel.org/r/20210714165806.2617325-1-sudeep.holla@arm.comSigned-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parents 5f291bfd dd925db6
...@@ -46,9 +46,6 @@ static int ffa_device_probe(struct device *dev) ...@@ -46,9 +46,6 @@ static int ffa_device_probe(struct device *dev)
struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver); struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver);
struct ffa_device *ffa_dev = to_ffa_dev(dev); struct ffa_device *ffa_dev = to_ffa_dev(dev);
if (!ffa_device_match(dev, dev->driver))
return -ENODEV;
return ffa_drv->probe(ffa_dev); return ffa_drv->probe(ffa_dev);
} }
...@@ -99,6 +96,9 @@ int ffa_driver_register(struct ffa_driver *driver, struct module *owner, ...@@ -99,6 +96,9 @@ int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
{ {
int ret; int ret;
if (!driver->probe)
return -EINVAL;
driver->driver.bus = &ffa_bus_type; driver->driver.bus = &ffa_bus_type;
driver->driver.name = driver->name; driver->driver.name = driver->name;
driver->driver.owner = owner; driver->driver.owner = owner;
......
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
#define PACK_TARGET_INFO(s, r) \ #define PACK_TARGET_INFO(s, r) \
(FIELD_PREP(SENDER_ID_MASK, (s)) | FIELD_PREP(RECEIVER_ID_MASK, (r))) (FIELD_PREP(SENDER_ID_MASK, (s)) | FIELD_PREP(RECEIVER_ID_MASK, (r)))
/** /*
* FF-A specification mentions explicitly about '4K pages'. This should * FF-A specification mentions explicitly about '4K pages'. This should
* not be confused with the kernel PAGE_SIZE, which is the translation * not be confused with the kernel PAGE_SIZE, which is the translation
* granule kernel is configured and may be one among 4K, 16K and 64K. * granule kernel is configured and may be one among 4K, 16K and 64K.
...@@ -149,8 +149,10 @@ static const int ffa_linux_errmap[] = { ...@@ -149,8 +149,10 @@ static const int ffa_linux_errmap[] = {
static inline int ffa_to_linux_errno(int errno) static inline int ffa_to_linux_errno(int errno)
{ {
if (errno < FFA_RET_SUCCESS && errno >= -ARRAY_SIZE(ffa_linux_errmap)) int err_idx = -errno;
return ffa_linux_errmap[-errno];
if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap))
return ffa_linux_errmap[err_idx];
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment