From 6eabefcf9f7201f40822d37cee287fd3b5eb040e Mon Sep 17 00:00:00 2001 From: Michal Hlavinka Date: Mon, 15 Nov 2010 15:43:34 +0100 Subject: [PATCH] - megaraid: Fix segfault on non-data commands (#577935) --- smartmontools-5.40-megaraid.patch | 33 +++++++++++++++++++++++++++++++ smartmontools.spec | 10 +++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 smartmontools-5.40-megaraid.patch diff --git a/smartmontools-5.40-megaraid.patch b/smartmontools-5.40-megaraid.patch new file mode 100644 index 0000000..3c3f8bc --- /dev/null +++ b/smartmontools-5.40-megaraid.patch @@ -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; diff --git a/smartmontools.spec b/smartmontools.spec index 000d6ef..5ede9e4 100644 --- a/smartmontools.spec +++ b/smartmontools.spec @@ -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 - 1:5.40-3 +- megaraid: Fix segfault on non-data commands (#577935) + * Tue Nov 09 2010 Michal Hlavinka - 1:5.40-2 - don't forget to restart smartd service after update (#651211)