From: Markus Elfring <Markus.Elfring@web.de>
To: linux-usb@vger.kernel.org,
Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
Chris Wulff <Chris.Wulff@biamp.com>,
Christian Brauner <brauner@kernel.org>,
David Sands <david.sands@biamp.com>,
Felipe Balbi <felipe.balbi@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jeff Johnson <quic_jjohnson@quicinc.com>,
Paul Cercueil <paul@crapouillou.net>,
Peter Korsgaard <peter@korsgaard.com>,
Tudor Ambarus <tudor.ambarus@linaro.org>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] usb: gadget: f_fs: Use common error handling code in ffs_build_sg_list()
Date: Wed, 25 Sep 2024 18:15:25 +0200 [thread overview]
Message-ID: <913884b5-c2b0-412e-a271-4053cbfb9e46@web.de> (raw)
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
reply other threads:[~2024-09-25 16:16 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=913884b5-c2b0-412e-a271-4053cbfb9e46@web.de \
--to=markus.elfring@web.de \
--cc=Chris.Wulff@biamp.com \
--cc=andrzej.p@samsung.com \
--cc=brauner@kernel.org \
--cc=david.sands@biamp.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=paul@crapouillou.net \
--cc=peter@korsgaard.com \
--cc=quic_jjohnson@quicinc.com \
--cc=tudor.ambarus@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®