]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
linux/ofpath: Fix error handling.
authorVladimir Serbinenko <phcoder@gmail.com>
Tue, 27 Jan 2015 15:49:49 +0000 (16:49 +0100)
committerVladimir Serbinenko <phcoder@gmail.com>
Tue, 27 Jan 2015 15:49:49 +0000 (16:49 +0100)
Found by: Coverity Scan.

grub-core/osdep/linux/ofpath.c

index 4cc171cb505ee424ecb929a0dbc55db87c2dd82a..f716fd2fc9f38800c9d5294e6c9c4c0b906597b8 100644 (file)
@@ -334,7 +334,7 @@ vendor_is_ATA(const char *path)
 }
 
 static void
-check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address)
+check_sas (const char *sysfs_path, int *tgt, unsigned long int *sas_address)
 {
   char *ed = strstr (sysfs_path, "end_device");
   char *p, *q, *path;
@@ -346,8 +346,10 @@ check_sas (char *sysfs_path, int *tgt, unsigned long int *sas_address)
     return;
 
   /* SAS devices are identified using disk@$PHY_ID */
-  p = strdup (sysfs_path);
+  p = xstrdup (sysfs_path);
   ed = strstr(p, "end_device");
+  if (!ed)
+    return;
 
   q = ed;
   while (*q && *q != '/')