usb: gadget: f_fs: Use common error handling code in ffs_build_sg_list()
Subsystems (2)
PATCH 1/1 usb: gadget: f_fs: Use common error handling code in ffs_build_sg_list()
From: Markus Elfring <[email protected]>
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 <[email protected]>
--- drivers/usb/gadget/function/f_fs.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/usb/gadget/function/f_fs.c +7 -7
@@ -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