- megaraid: Fix segfault on non-data commands (#577935)

This commit is contained in:
Michal Hlavinka 2010-11-15 15:43:34 +01:00
parent 5445ecdef8
commit 6eabefcf9f
2 changed files with 42 additions and 1 deletions

View File

@ -0,0 +1,33 @@
diff -up smartmontools-5.39.1/os_linux.cpp.megaraid smartmontools-5.39.1/os_linux.cpp
--- smartmontools-5.39.1/os_linux.cpp.megaraid 2010-01-28 21:24:32.000000000 +0100
+++ smartmontools-5.39.1/os_linux.cpp 2010-11-15 12:58:56.648181400 +0100
@@ -1095,17 +1095,21 @@ bool linux_megaraid_device::megasas_cmd(
pthru->cdb_len = cdbLen;
pthru->timeout = 0;
pthru->flags = MFI_FRAME_DIR_READ;
- pthru->sge_count = 1;
- pthru->data_xfer_len = dataLen;
- pthru->sgl.sge32[0].phys_addr = (intptr_t)data;
- pthru->sgl.sge32[0].length = (uint32_t)dataLen;
+ if (dataLen > 0) {
+ pthru->sge_count = 1;
+ pthru->data_xfer_len = dataLen;
+ pthru->sgl.sge32[0].phys_addr = (intptr_t)data;
+ pthru->sgl.sge32[0].length = (uint32_t)dataLen;
+ }
memcpy(pthru->cdb, cdb, cdbLen);
uio.host_no = m_hba;
- uio.sge_count = 1;
- uio.sgl_off = offsetof(struct megasas_pthru_frame, sgl);
- uio.sgl[0].iov_base = data;
- uio.sgl[0].iov_len = dataLen;
+ if (dataLen > 0) {
+ uio.sge_count = 1;
+ uio.sgl_off = offsetof(struct megasas_pthru_frame, sgl);
+ uio.sgl[0].iov_base = data;
+ uio.sgl[0].iov_len = dataLen;
+ }
rc = 0;
errno = 0;

View File

@ -1,7 +1,7 @@
Summary: Tools for monitoring SMART capable hard disks
Name: smartmontools
Version: 5.40
Release: 2%{?dist}
Release: 3%{?dist}
Epoch: 1
Group: System Environment/Base
License: GPLv2+
@ -13,6 +13,9 @@ Source2: smartmontools.sysconf
#fedora/rhel specific
Patch1: smartmontools-5.38-defaultconf.patch
#from upstream, for smartmontools <= 5.40
Patch2: smartmontools-5.40-megaraid.patch
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
Requires: fileutils mailx chkconfig initscripts
BuildRequires: readline-devel ncurses-devel automake util-linux groff gettext
@ -29,6 +32,8 @@ failure.
%prep
%setup -q
%patch1 -p1 -b .defaultconf
%patch2 -p1 -b .megaraid
# fix encoding
for fe in AUTHORS CHANGELOG
do
@ -86,6 +91,9 @@ fi
%{_datadir}/%{name}/drivedb.h
%changelog
* Mon Nov 15 2010 Michal Hlavinka <mhlavink@redhat.com> - 1:5.40-3
- megaraid: Fix segfault on non-data commands (#577935)
* Tue Nov 09 2010 Michal Hlavinka <mhlavink@redhat.com> - 1:5.40-2
- don't forget to restart smartd service after update (#651211)