[PATCH] scsi: qedf: Fix possible buffer overflow

From: Artem Chernyshev
Date: Fri Dec 02 2022 - 16:46:21 EST


In __qedf_probe() it is possible to overflow buffer host_buf[20]
and form non terminated string as result of passing large enough
(10 digits) number what gives us string of length 21 in sprintf()
function

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 61d8658b4a43 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: Artem Chernyshev <artem.chernyshev@xxxxxxxxxxx>
---
drivers/scsi/qedf/qedf_main.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index e045c6e25090..bab54fa07dfc 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -3287,7 +3287,7 @@ static int __qedf_probe(struct pci_dev *pdev, int mode)
struct Scsi_Host *host;
bool is_vf = false;
struct qed_ll2_params params;
- char host_buf[20];
+ char host_buf[21];
struct qed_link_params link_params;
int status;
void *task_start, *task_end;
--
2.30.3