lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <913884b5-c2b0-412e-a271-4053cbfb9e46@web.de>
Date: Wed, 25 Sep 2024 18:15:25 +0200
From: Markus Elfring <Markus.Elfring@....de>
To: linux-usb@...r.kernel.org, Andrzej Pietrasiewicz <andrzej.p@...sung.com>,
 Chris Wulff <Chris.Wulff@...mp.com>, Christian Brauner <brauner@...nel.org>,
 David Sands <david.sands@...mp.com>,
 Felipe Balbi <felipe.balbi@...ux.intel.com>,
 Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 Jeff Johnson <quic_jjohnson@...cinc.com>,
 Paul Cercueil <paul@...pouillou.net>, Peter Korsgaard <peter@...sgaard.com>,
 Tudor Ambarus <tudor.ambarus@...aro.org>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org
Subject: [PATCH] usb: gadget: f_fs: Use common error handling code in
 ffs_build_sg_list()

From: Markus Elfring <elfring@...rs.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@...rs.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


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ