Skip to content

Commit 0f88fc8

Browse files
committed
soc: apple: rtkit: Use scope-based cleanup in apple_rtkit_crashlog_rx()
Use scope-based cleanup for the crashlog buffer to simplify the function and avoid problems like the one fixed in commit 1fb9f14458c0 ("soc: apple: rtkit: Fix use-after-free in apple_rtkit_crashlog_rx()"). Signed-off-by: Janne Grunau <j@jannau.net>
1 parent a8b6518 commit 0f88fc8

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

drivers/soc/apple/rtkit.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ static void apple_rtkit_memcpy(struct apple_rtkit *rtk, void *dst,
361361
static void apple_rtkit_crashlog_rx(struct apple_rtkit *rtk, u64 msg)
362362
{
363363
u8 type = FIELD_GET(APPLE_RTKIT_SYSLOG_TYPE, msg);
364-
u8 *bfr;
364+
u8 *bfr __free(kfree) = NULL;
365365

366366
if (type != APPLE_RTKIT_CRASHLOG_CRASH) {
367367
dev_warn(rtk->dev, "RTKit: Unknown crashlog message: %llx\n",
@@ -395,8 +395,6 @@ static void apple_rtkit_crashlog_rx(struct apple_rtkit *rtk, u64 msg)
395395
rtk->crashed = true;
396396
if (rtk->ops->crashed)
397397
rtk->ops->crashed(rtk->cookie, bfr, rtk->crashlog_buffer.size);
398-
399-
kfree(bfr);
400398
}
401399

402400
static void apple_rtkit_ioreport_rx(struct apple_rtkit *rtk, u64 msg)

0 commit comments

Comments
 (0)