From ce06694de49f4e80cb74ff5fab3bf5b130055c25 Mon Sep 17 00:00:00 2001 From: samm2 <samm2@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sat, 12 Sep 2009 08:28:06 +0000 Subject: [PATCH] use malloc() to ensure that read buffer lands on a single page. This avoids some bugs seen on LSI controler under FreeBSD. git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2904 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/CHANGELOG | 4 ++++ smartmontools/scsiata.cpp | 10 ++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index ee4dfed4a..8bdd5c749 100644 --- a/smartmontools/CHANGELOG +++ b/smartmontools/CHANGELOG @@ -43,6 +43,10 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [AS] Use malloc() to ensure that the read buffer lands on a single + page. This avoids some bugs seen on LSI controlers under + FreeBSD. + [CF] Add missing help text for '-d usb*' options. [CF] Linux: Dereference '/dev/disk/by-*/*' symlink before device type diff --git a/smartmontools/scsiata.cpp b/smartmontools/scsiata.cpp index 0b61c93e7..ee0676512 100644 --- a/smartmontools/scsiata.cpp +++ b/smartmontools/scsiata.cpp @@ -48,6 +48,7 @@ #include <stdio.h> #include <string.h> +#include <stdlib.h> #include <ctype.h> #include "config.h" @@ -432,11 +433,16 @@ bool sat_device::ata_pass_through(const ata_cmd_in & in, ata_cmd_out & out) static bool has_sat_pass_through(ata_device * dev, bool packet_interface = false) { + /* Note: malloc() ensures the read buffer lands on a single + page. This avoids some bugs seen on LSI controlers under + FreeBSD */ + char *data = (char *)malloc(512); ata_cmd_in in; in.in_regs.command = (packet_interface ? ATA_IDENTIFY_PACKET_DEVICE : ATA_IDENTIFY_DEVICE); - char data[512]; in.set_data_in(data, 1); - return dev->ata_pass_through(in); + bool ret = dev->ata_pass_through(in); + free(data); + return ret; } ///////////////////////////////////////////////////////////////////////////// -- GitLab