aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/message
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2017-07-17 08:00:00 -0400
committerMartin K. Petersen <martin.petersen@oracle.com>2017-08-07 14:04:02 -0400
commitb192b42a70393c5194acf48c65d320c824f1d261 (patch)
tree079446ef98073b111c8901603177fe8b7691c9d0 /drivers/message
parent345ebae7d0586d2f945b622f67f4027515ec4d40 (diff)
scsi: fusion: fix string overflow warning
gcc points out a theorerical string overflow: drivers/message/fusion/mptbase.c: In function 'mpt_detach': drivers/message/fusion/mptbase.c:2103:17: error: '%s' directive writing up to 31 bytes into a region of size 28 [-Werror=format-overflow=] sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); ^~~~~ drivers/message/fusion/mptbase.c:2103:2: note: 'sprintf' output between 13 and 44 bytes into a destination of size 32 We can simply double the size of the local buffer here to be on the safe side, and using snprintf() instead of sprintf() protects us if ioc->name was not terminated properly. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/message')
-rw-r--r--drivers/message/fusion/mptbase.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 62cff5afc6bd..84eab28665f3 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -2079,7 +2079,7 @@ void
2079mpt_detach(struct pci_dev *pdev) 2079mpt_detach(struct pci_dev *pdev)
2080{ 2080{
2081 MPT_ADAPTER *ioc = pci_get_drvdata(pdev); 2081 MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
2082 char pname[32]; 2082 char pname[64];
2083 u8 cb_idx; 2083 u8 cb_idx;
2084 unsigned long flags; 2084 unsigned long flags;
2085 struct workqueue_struct *wq; 2085 struct workqueue_struct *wq;
@@ -2100,11 +2100,11 @@ mpt_detach(struct pci_dev *pdev)
2100 spin_unlock_irqrestore(&ioc->fw_event_lock, flags); 2100 spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
2101 destroy_workqueue(wq); 2101 destroy_workqueue(wq);
2102 2102
2103 sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name); 2103 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name);
2104 remove_proc_entry(pname, NULL); 2104 remove_proc_entry(pname, NULL);
2105 sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/info", ioc->name); 2105 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s/info", ioc->name);
2106 remove_proc_entry(pname, NULL); 2106 remove_proc_entry(pname, NULL);
2107 sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s", ioc->name); 2107 snprintf(pname, sizeof(pname), MPT_PROCFS_MPTBASEDIR "/%s", ioc->name);
2108 remove_proc_entry(pname, NULL); 2108 remove_proc_entry(pname, NULL);
2109 2109
2110 /* call per device driver remove entry point */ 2110 /* call per device driver remove entry point */