scsi: qedi: Use snprintf instead of sprintf
authorManish Rangankar <mrangankar@marvell.com>
Tue, 8 Sep 2020 09:56:54 +0000 (02:56 -0700)
committerMartin K. Petersen <martin.petersen@oracle.com>
Wed, 9 Sep 2020 02:40:23 +0000 (22:40 -0400)
Use snprintf to limit max number of bytes to the buffer.

Link: https://lore.kernel.org/r/20200908095657.26821-6-mrangankar@marvell.com
Signed-off-by: Manish Rangankar <mrangankar@marvell.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/qedi/qedi_main.c

index c6842af1f21bcd04f67553e2379bc70a167d7a76..15b78e1783c2b1381de12289a436aa8a11656fd3 100644 (file)
@@ -2537,7 +2537,7 @@ static int __qedi_probe(struct pci_dev *pdev, int mode)
        QEDI_INFO(&qedi->dbg_ctx, QEDI_LOG_DISC, "MAC address is %pM.\n",
                  qedi->mac);
 
-       sprintf(host_buf, "host_%d", qedi->shost->host_no);
+       snprintf(host_buf, sizeof(host_buf), "host_%d", qedi->shost->host_no);
        qedi_ops->common->set_name(qedi->cdev, host_buf);
 
        qedi_ops->register_ops(qedi->cdev, &qedi_cb_ops, qedi);