From: Vladimir Serbinenko Date: Tue, 27 Jan 2015 15:49:49 +0000 (+0100) Subject: linux/ofpath: Fix error handling. X-Git-Tag: 2.02-beta3~465 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8f95eae423fc7220af3c1f6150ac35e98281bb96;p=thirdparty%2Fgrub.git linux/ofpath: Fix error handling. Found by: Coverity Scan. --- diff --git a/grub-core/osdep/linux/ofpath.c b/grub-core/osdep/linux/ofpath.c index 4cc171cb5..f716fd2fc 100644 --- a/grub-core/osdep/linux/ofpath.c +++ b/grub-core/osdep/linux/ofpath.c @@ -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 != '/')