* [PATCH] usb: gadget: f_fs: Use common error handling code in ffs_build_sg_list()
@ 2024-09-25 16:15 Markus Elfring
0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2024-09-25 16:15 UTC (permalink / raw)
To: linux-usb, Andrzej Pietrasiewicz, Chris Wulff, Christian Brauner,
David Sands, Felipe Balbi, Greg Kroah-Hartman, Jeff Johnson,
Paul Cercueil, Peter Korsgaard, Tudor Ambarus
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 25 Sep 2024 18:03:16 +0200
Add a jump target so that a bit of exception handling can be better reused
at the end of this function implementation.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/usb/gadget/function/f_fs.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
index 05b52e61a66f..318a74578c3f 100644
--- a/drivers/usb/gadget/function/f_fs.c
+++ b/drivers/usb/gadget/function/f_fs.c
@@ -808,23 +808,23 @@ static void *ffs_build_sg_list(struct sg_table *sgt, size_t sz)
n_pages = PAGE_ALIGN(sz) >> PAGE_SHIFT;
pages = kvmalloc_array(n_pages, sizeof(struct page *), GFP_KERNEL);
- if (!pages) {
- vfree(vaddr);
+ if (!pages)
+ goto free_vaddr;
- return NULL;
- }
for (i = 0, ptr = vaddr; i < n_pages; ++i, ptr += PAGE_SIZE)
pages[i] = vmalloc_to_page(ptr);
if (sg_alloc_table_from_pages(sgt, pages, n_pages, 0, sz, GFP_KERNEL)) {
kvfree(pages);
- vfree(vaddr);
-
- return NULL;
+ goto free_vaddr;
}
kvfree(pages);
return vaddr;
+
+free_vaddr:
+ vfree(vaddr);
+ return NULL;
}
static inline void *ffs_alloc_buffer(struct ffs_io_data *io_data,
--
2.46.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-09-25 16:16 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-25 16:15 [PATCH] usb: gadget: f_fs: Use common error handling code in ffs_build_sg_list() Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®