mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH TRIVIAL]: 2.4.19/drivers/acorn/block/fd1772.c
@ 2002-08-24 10:03 silvio
  0 siblings, 0 replies; only message in thread
From: silvio @ 2002-08-24 10:03 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 49 bytes --]

trivial patch to add check on kmalloc

--
Silvio

[-- Attachment #2: patch.linux1 --]
[-- Type: text/plain, Size: 1418 bytes --]

--- linux-2.4.19/drivers/acorn/block/fd1772.c	Fri Aug  2 17:39:43 2002
+++ linux-2.4.19-dev/drivers/acorn/block/fd1772.c	Sat Aug 24 02:38:49 2002
@@ -1567,6 +1567,7 @@
 
 int fd1772_init(void)
 {
+	int err;
 	int i;
 
 	if (!machine_is_archimedes())
@@ -1584,24 +1585,28 @@
 
 	if (request_dma(FIQ_FD1772, "fd1772 end")) {
 		printk("Unable to grab DMA%d for the floppy (1772) driver\n", FIQ_FD1772);
-		free_dma(FLOPPY_DMA);
-		return 1;
+		err = 1; /* XXX */
+		goto cleanup_dma;
 	};
-	enable_dma(FIQ_FD1772);	/* This inserts a call to our command end routine */
 
 	/* initialize variables */
+	err = -ENOMEM;
 	SelectedDrive = -1;
 #ifdef TRACKBUFFER
 	BufferDrive = BufferSide = BufferTrack = -1;
 	/* Atari uses 512 - I want to eventually cope with 1K sectors */
 	DMABuffer = (char *)kmalloc((FD1772_MAX_SECTORS+1)*512,GFP_KERNEL);
+	if (DMABuffer == NULL)
+		goto cleanup_dma;
 	TrackBuffer = DMABuffer + 512;
 #else
 	/* Allocate memory for the DMAbuffer - on the Atari this takes it
 	   out of some special memory... */
 	DMABuffer = (char *) kmalloc(2048);	/* Copes with pretty large sectors */
+	if (DMABuffer == NULL)
+		goto cleanup_dma;
 #endif
-
+	enable_dma(FIQ_FD1772);	/* This inserts a call to our command end routine */
 	for (i = 0; i < FD_MAX_UNITS; i++) {
 		unit[i].track = -1;
 	}
@@ -1619,4 +1624,7 @@
 	config_types();
 
 	return 0;
+cleanup_dma:
+	free_dma(FLOPPY_DMA);
+	return err;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2002-08-24  9:53 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-24 10:03 [PATCH TRIVIAL]: 2.4.19/drivers/acorn/block/fd1772.c silvio

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®