Skip to content

Commit d28912d

Browse files
committed
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/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 5f291bf + dd925db commit d28912d

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

drivers/firmware/arm_ffa/bus.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ static int ffa_device_probe(struct device *dev)
4646
struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver);
4747
struct ffa_device *ffa_dev = to_ffa_dev(dev);
4848

49-
if (!ffa_device_match(dev, dev->driver))
50-
return -ENODEV;
51-
5249
return ffa_drv->probe(ffa_dev);
5350
}
5451

@@ -99,6 +96,9 @@ int ffa_driver_register(struct ffa_driver *driver, struct module *owner,
9996
{
10097
int ret;
10198

99+
if (!driver->probe)
100+
return -EINVAL;
101+
102102
driver->driver.bus = &ffa_bus_type;
103103
driver->driver.name = driver->name;
104104
driver->driver.owner = owner;

drivers/firmware/arm_ffa/driver.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
#define PACK_TARGET_INFO(s, r) \
121121
(FIELD_PREP(SENDER_ID_MASK, (s)) | FIELD_PREP(RECEIVER_ID_MASK, (r)))
122122

123-
/**
123+
/*
124124
* FF-A specification mentions explicitly about '4K pages'. This should
125125
* not be confused with the kernel PAGE_SIZE, which is the translation
126126
* granule kernel is configured and may be one among 4K, 16K and 64K.
@@ -149,8 +149,10 @@ static const int ffa_linux_errmap[] = {
149149

150150
static inline int ffa_to_linux_errno(int errno)
151151
{
152-
if (errno < FFA_RET_SUCCESS && errno >= -ARRAY_SIZE(ffa_linux_errmap))
153-
return ffa_linux_errmap[-errno];
152+
int err_idx = -errno;
153+
154+
if (err_idx >= 0 && err_idx < ARRAY_SIZE(ffa_linux_errmap))
155+
return ffa_linux_errmap[err_idx];
154156
return -EINVAL;
155157
}
156158

0 commit comments

Comments
 (0)