Skip to content

Commit b00773d

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 e3e3884 commit b00773d

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
@@ -362,7 +362,7 @@ static void apple_rtkit_memcpy(struct apple_rtkit *rtk, void *dst,
362362
static void apple_rtkit_crashlog_rx(struct apple_rtkit *rtk, u64 msg)
363363
{
364364
u8 type = FIELD_GET(APPLE_RTKIT_SYSLOG_TYPE, msg);
365-
u8 *bfr;
365+
u8 *bfr __free(kfree) = NULL;
366366

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

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

0 commit comments

Comments
 (0)