Merge lp:~swem/ubuntu/trusty/lshw/lp1471983 into lp:ubuntu/trusty-proposed/lshw

Proposed by Chen-Han Hsiao (Stanley)
Status: Needs review
Proposed branch: lp:~swem/ubuntu/trusty/lshw/lp1471983
Merge into: lp:ubuntu/trusty-proposed/lshw
Diff against target: 184 lines (+159/-0)
4 files modified
debian/changelog (+7/-0)
debian/patches/presumably-fix-653.patch (+30/-0)
debian/patches/series (+2/-0)
debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch (+120/-0)
To merge this branch: bzr merge lp:~swem/ubuntu/trusty/lshw/lp1471983
Reviewer Review Type Date Requested Status
Marc Deslauriers Needs Fixing
Review via email: mp+270012@code.launchpad.net

Description of the change

For bug 1471983, I also encounter this issue in Ubuntu OEM project.

This bug is fixed in https://github.com/lyonel/lshw/commit/d048d300b5daeb44887a7fc06ddeb120119cac8a

The issue in upstream: [lshw segfaults, with some 16GB USB-3 sticks from Patriot] http://www.ezix.org/project/ticket/653

I've made a patch to fix it.

To post a comment you must log in.
Revision history for this message
Marc Deslauriers (mdeslaur) wrote :

Hi, thanks for the debdiff!

Two comments:

1- Could you please list both patches in the changelog along with a small description of what they accomplish?
2- While the "use-a-different-approach-for-scanning-SCSI-generic-d.patch" change seems to be included in 2.17 currently in vivid and wily, the "presumably-fix-653.patch" change is not. Could you please prepare debdiffs for Vivid and Wily?

Thanks!

review: Needs Fixing
Revision history for this message
Chen-Han Hsiao (Stanley) (swem) wrote :

@mdeslaur, thanks for review.

1. There are two patches added. I would add this description to changelog.

   [d048d30] presumably-fix-653.patch is for this segmentation fault issue.

   [b79f299] use-a-different-approach-for-scanning-SCSI-generic-d.patch use different approach to scan scsi devices to cover general devices. The functionality is the same. This patch need to be applied before d048d30.

2. I will add debdiff for vivid and wily

33. By Chen-Han Hsiao (Stanley)

* [d048d30] Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)
* [b79f299] Use different approach for scanning SCSI generic devices.

Unmerged revisions

33. By Chen-Han Hsiao (Stanley)

* [d048d30] Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)
* [b79f299] Use different approach for scanning SCSI generic devices.

32. By Chen-Han Hsiao (Stanley)

Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2015-08-28 15:00:23 +0000
+++ debian/changelog 2015-10-06 02:29:16 +0000
@@ -1,3 +1,10 @@
1lshw (02.16-2ubuntu1.4) trusty-proposed; urgency=medium
2
3 * [d048d30] Fix lshw crash issue on system with some USB-3 sticks (LP: #1471983)
4 * [b79f299] Use different approach for scanning SCSI generic devices.
5
6 -- Chen-Han Hsiao (Stanley) <stanley.hsiao@canonical.com> Wed, 19 Aug 2015 11:58:11 +0800
7
1lshw (02.16-2ubuntu1.3) trusty-proposed; urgency=medium8lshw (02.16-2ubuntu1.3) trusty-proposed; urgency=medium
29
3 * Backport cpuinfo support for aarch64 (LP: #1485086)10 * Backport cpuinfo support for aarch64 (LP: #1485086)
411
=== added file 'debian/patches/presumably-fix-653.patch'
--- debian/patches/presumably-fix-653.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/presumably-fix-653.patch 2015-10-06 02:29:16 +0000
@@ -0,0 +1,30 @@
1From d048d300b5daeb44887a7fc06ddeb120119cac8a Mon Sep 17 00:00:00 2001
2From: Lyonel Vincent <lyonel@ezix.org>
3Date: Sun, 13 Jul 2014 11:21:59 +0000
4Subject: [PATCH] (presumably) fix #653
5
6git-svn-id: http://ezix.org/source/packages/lshw/development@2535 811e2811-9fd9-0310-a116-b6e8ac943c8b
7---
8 src/core/scsi.cc | 6 +++---
9 1 file changed, 3 insertions(+), 3 deletions(-)
10
11diff --git a/src/core/scsi.cc b/src/core/scsi.cc
12index ed059cb..d85fcc8 100644
13--- a/src/core/scsi.cc
14+++ b/src/core/scsi.cc
15@@ -481,9 +481,9 @@ hwNode & node)
16 memset(rsp_buff, 0, sizeof(rsp_buff));
17 if (do_inq(sg_fd, 0, 1, 0x80, rsp_buff, MX_ALLOC_LEN, 0))
18 {
19- len = rsp_buff[3];
20- if (len > 0)
21- node.setSerial(hw::strip(string(rsp_buff + 4, len)));
22+ char _len = rsp_buff[3];
23+ if (_len > 0)
24+ node.setSerial(hw::strip(string(rsp_buff + 4, _len)));
25 }
26
27 memset(rsp_buff, 0, sizeof(rsp_buff));
28--
291.9.1
30
031
=== modified file 'debian/patches/series'
--- debian/patches/series 2015-08-28 15:00:23 +0000
+++ debian/patches/series 2015-10-06 02:29:16 +0000
@@ -17,3 +17,5 @@
17ddr3-device-tree-support.patch17ddr3-device-tree-support.patch
18Do-not-brutally-merge-NICs-in-the-same-PCI-function-.patch18Do-not-brutally-merge-NICs-in-the-same-PCI-function-.patch
19cpuinfo-arm-aarch64-support.patch19cpuinfo-arm-aarch64-support.patch
20presumably-fix-653.patch
21use-a-different-approach-for-scanning-SCSI-generic-d.patch
2022
=== added file 'debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch'
--- debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch 1970-01-01 00:00:00 +0000
+++ debian/patches/use-a-different-approach-for-scanning-SCSI-generic-d.patch 2015-10-06 02:29:16 +0000
@@ -0,0 +1,120 @@
1From b79f299319f61bc80e8d38e61631cfee7521a729 Mon Sep 17 00:00:00 2001
2From: lyonel <lyonel@811e2811-9fd9-0310-a116-b6e8ac943c8b>
3Date: Wed, 13 Mar 2013 20:52:25 +0000
4Subject: [PATCH] use a different approach for scanning SCSI generic devices
5 (`/dev/sg*`) to fix #541 (thanks to Wayne Boyer)
6
7git-svn-id: http://ezix.org/source/packages/lshw/development@2518 811e2811-9fd9-0310-a116-b6e8ac943c8b
8---
9 src/core/scsi.cc | 45 ++++++++++++++++++++++++---------------------
10 1 file changed, 24 insertions(+), 21 deletions(-)
11
12diff --git a/src/core/scsi.cc b/src/core/scsi.cc
13index 926ae06..ed059cb 100644
14--- a/src/core/scsi.cc
15+++ b/src/core/scsi.cc
16@@ -29,7 +29,7 @@
17
18 __ID("@(#) $Id$");
19
20-#define SG_X "/dev/sg%d"
21+#define SG_X "/dev/sg*"
22 #define SG_MAJOR 21
23
24 #ifndef SCSI_IOCTL_GET_PCI
25@@ -653,10 +653,9 @@ static bool atapi(const hwNode & n)
26 }
27
28
29-static bool scan_sg(int sg,
30-hwNode & n)
31+static void scan_sg(hwNode & n)
32 {
33- char buffer[20];
34+ int sg;
35 int fd = -1;
36 My_sg_scsi_id m_id;
37 char slot_name[64]; // should be 16 but some 2.6 kernels require 32 bytes
38@@ -665,22 +664,30 @@ hwNode & n)
39 hwNode *parent = NULL;
40 int emulated = 0;
41 bool ghostdeventry = false;
42+ size_t j;
43+ glob_t entries;
44
45- snprintf(buffer, sizeof(buffer), SG_X, sg);
46+ if(glob(SG_X, 0, NULL, &entries) == 0)
47+ {
48+ for(j=0; j < entries.gl_pathc; j++)
49+ {
50+ sg = strtol(strpbrk(entries.gl_pathv[j], "0123456789"), NULL, 10);
51
52- ghostdeventry = !exists(buffer);
53+ ghostdeventry = !exists(entries.gl_pathv[j]);
54
55- if(ghostdeventry) mknod(buffer, (S_IFCHR | S_IREAD), MKDEV(SG_MAJOR, sg));
56- fd = open(buffer, OPEN_FLAG | O_NONBLOCK);
57- if(ghostdeventry) unlink(buffer);
58+ if(ghostdeventry)
59+ mknod(entries.gl_pathv[j], (S_IFCHR | S_IREAD), MKDEV(SG_MAJOR, sg));
60+ fd = open(entries.gl_pathv[j], OPEN_FLAG | O_NONBLOCK);
61+ if(ghostdeventry)
62+ unlink(entries.gl_pathv[j]);
63 if (fd < 0)
64- return false;
65+ continue;
66
67 memset(&m_id, 0, sizeof(m_id));
68 if (ioctl(fd, SG_GET_SCSI_ID, &m_id) < 0)
69 {
70 close(fd);
71- return true; // we failed to get info but still hope we can continue
72+ continue; // we failed to get info but still hope we can continue
73 }
74
75 emulated = 0;
76@@ -773,11 +780,8 @@ hwNode & n)
77 if (!parent)
78 parent = n.addChild(hwNode("scsi", hw::storage));
79
80- if (!parent)
81+ if (parent)
82 {
83- close(fd);
84- return true;
85- }
86
87 if(parent->getBusInfo() == "")
88 parent->setBusInfo(guessBusInfo(hw::strip(slot_name)));
89@@ -789,10 +793,12 @@ hwNode & n)
90 parent->addCapability("emulated", "Emulated device");
91 }
92 parent->addChild(device);
93+ }
94
95 close(fd);
96-
97- return true;
98+ }
99+ globfree(&entries);
100+ }
101 }
102
103
104@@ -889,12 +895,9 @@ static bool scan_hosts(hwNode & node)
105
106 bool scan_scsi(hwNode & n)
107 {
108- int i = 0;
109-
110 scan_devices();
111
112- while (scan_sg(i, n))
113- i++;
114+ scan_sg(n);
115
116 scan_hosts(n);
117
118--
1191.9.1
120

Subscribers

People subscribed via source and target branches