Skip to content

Commit df3ef89

Browse files
committed
Merge tag 'scmi-fixes-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux into arm/fixes
Arm SCMI fixes for v7.0 Few fixes to: 1. Address a NULL dereference in the SCMI notify error path by ensurin __scmi_event_handler_get_ops() consistently returns an ERR_PTR on failure, as expected by callers. 2. Fix a device_node reference leak in the SCPI probe path by introducing scope-based cleanup for acquired DT nodes. 3. Correct minor spelling errors. * tag 'scmi-fixes-7.0' of git://git.kernel.org/pub/scm/linux/kernel/git/sudeep.holla/linux: firmware: arm_scmi: Spelling s/mulit/multi/, s/currenly/currently/ firmware: arm_scmi: Fix NULL dereference on notify error path firmware: arm_scpi: Fix device_node reference leak in probe path Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents dfc80d6 + 4e701b4 commit df3ef89

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

drivers/firmware/arm_scmi/notify.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ static int scmi_register_event_handler(struct scmi_notify_instance *ni,
10661066
* since at creation time we usually want to have all setup and ready before
10671067
* events really start flowing.
10681068
*
1069-
* Return: A properly refcounted handler on Success, NULL on Failure
1069+
* Return: A properly refcounted handler on Success, ERR_PTR on Failure
10701070
*/
10711071
static inline struct scmi_event_handler *
10721072
__scmi_event_handler_get_ops(struct scmi_notify_instance *ni,
@@ -1113,7 +1113,7 @@ __scmi_event_handler_get_ops(struct scmi_notify_instance *ni,
11131113
}
11141114
mutex_unlock(&ni->pending_mtx);
11151115

1116-
return hndl;
1116+
return hndl ?: ERR_PTR(-ENODEV);
11171117
}
11181118

11191119
static struct scmi_event_handler *

drivers/firmware/arm_scmi/protocols.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,13 @@ struct scmi_protocol_handle {
189189

190190
/**
191191
* struct scmi_iterator_state - Iterator current state descriptor
192-
* @desc_index: Starting index for the current mulit-part request.
192+
* @desc_index: Starting index for the current multi-part request.
193193
* @num_returned: Number of returned items in the last multi-part reply.
194194
* @num_remaining: Number of remaining items in the multi-part message.
195195
* @max_resources: Maximum acceptable number of items, configured by the caller
196196
* depending on the underlying resources that it is querying.
197197
* @loop_idx: The iterator loop index in the current multi-part reply.
198-
* @rx_len: Size in bytes of the currenly processed message; it can be used by
198+
* @rx_len: Size in bytes of the currently processed message; it can be used by
199199
* the user of the iterator to verify a reply size.
200200
* @priv: Optional pointer to some additional state-related private data setup
201201
* by the caller during the iterations.

drivers/firmware/arm_scpi.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
#include <linux/bitmap.h>
2020
#include <linux/bitfield.h>
21+
#include <linux/cleanup.h>
2122
#include <linux/device.h>
2223
#include <linux/err.h>
2324
#include <linux/export.h>
@@ -940,13 +941,13 @@ static int scpi_probe(struct platform_device *pdev)
940941
int idx = scpi_drvinfo->num_chans;
941942
struct scpi_chan *pchan = scpi_drvinfo->channels + idx;
942943
struct mbox_client *cl = &pchan->cl;
943-
struct device_node *shmem = of_parse_phandle(np, "shmem", idx);
944+
struct device_node *shmem __free(device_node) =
945+
of_parse_phandle(np, "shmem", idx);
944946

945947
if (!of_match_node(shmem_of_match, shmem))
946948
return -ENXIO;
947949

948950
ret = of_address_to_resource(shmem, 0, &res);
949-
of_node_put(shmem);
950951
if (ret) {
951952
dev_err(dev, "failed to get SCPI payload mem resource\n");
952953
return ret;

0 commit comments

Comments
 (0)