Skip to content

Commit ea6fdb1

Browse files
committed
firewire: ohci: use cleanup helper for isoc context header allocation
Some cleanup helpers are useful in error path after memory allocation for header storage. Link: https://lore.kernel.org/r/20260117142823.440811-5-o-takashi@sakamocchi.jp Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
1 parent c544c82 commit ea6fdb1

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

drivers/firewire/ohci.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2958,6 +2958,7 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card,
29582958
int type, int channel, size_t header_size)
29592959
{
29602960
struct fw_ohci *ohci = fw_ohci(card);
2961+
void *header __free(free_page) = NULL;
29612962
struct iso_context *ctx;
29622963
descriptor_callback_t callback;
29632964
u64 *channels;
@@ -3015,30 +3016,26 @@ static struct fw_iso_context *ohci_allocate_iso_context(struct fw_card *card,
30153016

30163017
if (type != FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL) {
30173018
ctx->sc.header_length = 0;
3018-
ctx->sc.header = (void *) __get_free_page(GFP_KERNEL);
3019-
if (!ctx->sc.header) {
3019+
header = (void *) __get_free_page(GFP_KERNEL);
3020+
if (!header) {
30203021
ret = -ENOMEM;
30213022
goto out;
30223023
}
30233024
}
30243025

30253026
ret = context_init(&ctx->context, ohci, regs, callback);
30263027
if (ret < 0)
3027-
goto out_with_header;
3028+
goto out;
30283029
fw_iso_context_init_work(&ctx->base, ohci_isoc_context_work);
30293030

3030-
if (type == FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL) {
3031+
if (type != FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL) {
3032+
ctx->sc.header = no_free_ptr(header);
3033+
} else {
30313034
set_multichannel_mask(ohci, 0);
30323035
ctx->mc.completed = 0;
30333036
}
30343037

30353038
return &ctx->base;
3036-
3037-
out_with_header:
3038-
if (type != FW_ISO_CONTEXT_RECEIVE_MULTICHANNEL) {
3039-
free_page((unsigned long)ctx->sc.header);
3040-
ctx->sc.header = NULL;
3041-
}
30423039
out:
30433040
scoped_guard(spinlock_irq, &ohci->lock) {
30443041
switch (type) {

0 commit comments

Comments
 (0)