From 3ddb98cebda43e56ba023c5e12306a000a60a707 Mon Sep 17 00:00:00 2001 From: chrfranke Date: Wed, 28 Mar 2018 19:37:45 +0000 Subject: [PATCH 124/291] os_linux.cpp: Fix device scan crash on missing /proc/devices. git-svn-id: http://svn.code.sf.net/p/smartmontools/code/trunk@4723 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/ChangeLog | 2 ++ smartmontools/os_linux.cpp | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/smartmontools/os_linux.cpp b/smartmontools/os_linux.cpp index 6df97e94..29203409 100644 --- a/smartmontools/os_linux.cpp +++ b/smartmontools/os_linux.cpp @@ -5,7 +5,7 @@ * * Copyright (C) 2003-11 Bruce Allen * Copyright (C) 2003-11 Doug Gilbert - * Copyright (C) 2008-17 Christian Franke + * Copyright (C) 2008-18 Christian Franke * * Original AACRaid code: * Copyright (C) 2014 Raghava Aditya @@ -2961,6 +2961,8 @@ bool linux_smart_interface::get_dev_megasas(smart_device_list & devlist) char line[128]; bool scan_megasas = false; FILE * fp = fopen("/proc/devices", "r"); + if (!fp) + return false; while (fgets(line, sizeof(line), fp) != NULL) { n1=0; if (sscanf(line, "%d megaraid_sas_ioctl%n", &mjr, &n1) == 1 && n1 == 22) { -- 2.19.1