summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorJuergen Beisert <jbe@pengutronix.de>2010-10-08 18:30:51 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2010-10-11 13:08:26 +0200
commit5340589afcec8fad6df708b60888c45a8a6d08f9 (patch)
tree8d202e00df88e6efd2b303ef099b09e307b47b56 /drivers
parent0a3b6151512d3a8b34cc644157459654bd45fbb6 (diff)
downloadbarebox-5340589afcec8fad6df708b60888c45a8a6d08f9.tar.gz
barebox-5340589afcec8fad6df708b60888c45a8a6d08f9.tar.xz
Don't use a sector buffer on stack
Using a temp. buffer for a disk sector on the stack, seems not work. Doing so lets the system run crazy (the stack seems to be destroyd). Don't know the correct stack handling on ARM, but (IMHO) I also can exclude any writing across the buffer boundaries. Using a temp. buffer via malloc() runs also on ARM. Note: This patch was required to add MCI card support, which can be handled like a disk drive. Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/ata/disk_drive.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/drivers/ata/disk_drive.c b/drivers/ata/disk_drive.c
index 5b22e49974..15ef5f41b9 100644
--- a/drivers/ata/disk_drive.c
+++ b/drivers/ata/disk_drive.c
@@ -34,6 +34,7 @@
#include <errno.h>
#include <string.h>
#include <linux/kernel.h>
+#include <malloc.h>
/**
* Description of one partition table entry (D*S type)
@@ -269,15 +270,18 @@ static struct file_operations disk_ops = {
*/
static int disk_probe(struct device_d *dev)
{
- uint8_t sector[512];
+ uint8_t *sector;
int rc;
struct ata_interface *intf = dev->platform_data;
struct cdev *disk_cdev;
+ sector = xmalloc(SECTOR_SIZE);
+
rc = intf->read(dev, 0, 1, sector);
if (rc != 0) {
dev_err(dev, "Cannot read MBR of this device\n");
- return -1;
+ rc = -ENODEV;
+ goto on_error;
}
/* It seems a valuable disk. Register it */
@@ -306,7 +310,8 @@ static int disk_probe(struct device_d *dev)
if ((sector[510] != 0x55) || (sector[511] != 0xAA)) {
dev_info(dev, "No partition table found\n");
- return 0;
+ rc = 0;
+ goto on_error;
}
/* guess the size of this drive */
@@ -314,9 +319,11 @@ static int disk_probe(struct device_d *dev)
dev_info(dev, "Drive size guessed to %u kiB\n", dev->size / 1024);
disk_cdev->size = dev->size;
- disk_register_partitions(dev, (struct partition_entry*)&sector[446]);
+ rc = disk_register_partitions(dev, (struct partition_entry*)&sector[446]);
- return 0;
+on_error:
+ free(sector);
+ return rc;
}
#ifdef CONFIG_ATA_BIOS