diff mbox

scsi: qedi: return via va_end to match corresponding va_start

Message ID 20161216141043.22324-1-colin.king@canonical.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Colin King Dec. 16, 2016, 2:10 p.m. UTC
From: Colin Ian King <colin.king@canonical.com>

Although on most systems va_end is a no-op, it is good practice
to use va_end on the function return path, especially since the
va_start documenation states:

  "Each invocation of va_start() must be matched by a corresponding
   invocation of va_end() in the same function."

Found with static analysis by CoverityScan, CIDs 1389477-1389479

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 drivers/scsi/qedi/qedi_dbg.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Comments

Rangankar, Manish Dec. 22, 2016, 8:51 a.m. UTC | #1
On 16/12/16 7:40 PM, "Colin King" <colin.king@canonical.com> wrote:

>From: Colin Ian King <colin.king@canonical.com>
>
>Although on most systems va_end is a no-op, it is good practice
>to use va_end on the function return path, especially since the
>va_start documenation states:
>
>  "Each invocation of va_start() must be matched by a corresponding
>   invocation of va_end() in the same function."
>
>Found with static analysis by CoverityScan, CIDs 1389477-1389479
>
>Signed-off-by: Colin Ian King <colin.king@canonical.com>
>---
> drivers/scsi/qedi/qedi_dbg.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
>
>diff --git a/drivers/scsi/qedi/qedi_dbg.c b/drivers/scsi/qedi/qedi_dbg.c
>index 2bdedb9..8fd28b0 100644
>--- a/drivers/scsi/qedi/qedi_dbg.c
>+++ b/drivers/scsi/qedi/qedi_dbg.c
>@@ -52,7 +52,7 @@ qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
> 	vaf.va = &va;
> 
> 	if (!(qedi_dbg_log & QEDI_LOG_WARN))
>-		return;
>+		goto ret;
> 
> 	if (likely(qedi) && likely(qedi->pdev))
> 		pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
>@@ -60,6 +60,7 @@ qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
> 	else
> 		pr_warn("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
> 
>+ret:
> 	va_end(va);
> }
> 
>@@ -80,7 +81,7 @@ qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
> 	vaf.va = &va;
> 
> 	if (!(qedi_dbg_log & QEDI_LOG_NOTICE))
>-		return;
>+		goto ret;
> 
> 	if (likely(qedi) && likely(qedi->pdev))
> 		pr_notice("[%s]:[%s:%d]:%d: %pV",
>@@ -89,6 +90,7 @@ qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
> 	else
> 		pr_notice("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
> 
>+ret:
> 	va_end(va);
> }
> 
>@@ -109,7 +111,7 @@ qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
> 	vaf.va = &va;
> 
> 	if (!(qedi_dbg_log & level))
>-		return;
>+		goto ret;
> 
> 	if (likely(qedi) && likely(qedi->pdev))
> 		pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
>@@ -117,6 +119,7 @@ qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char
>*func, u32 line,
> 	else
> 		pr_info("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
> 
>+ret:
> 	va_end(va);
> }
> 
>-- 
>2.10.2


Acked-by: Manish Rangankar <manish.rangankar@cavium.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Martin K. Petersen Jan. 5, 2017, 5:32 a.m. UTC | #2
>>>>> "Colin" == Colin King <colin.king@canonical.com> writes:

Colin> Although on most systems va_end is a no-op, it is good practice
Colin> to use va_end on the function return path, especially since the
Colin> va_start documenation states:

Colin>   "Each invocation of va_start() must be matched by a
Colin>   corresponding
Colin>    invocation of va_end() in the same function."

Applied to 4.11/scsi-queue.
diff mbox

Patch

diff --git a/drivers/scsi/qedi/qedi_dbg.c b/drivers/scsi/qedi/qedi_dbg.c
index 2bdedb9..8fd28b0 100644
--- a/drivers/scsi/qedi/qedi_dbg.c
+++ b/drivers/scsi/qedi/qedi_dbg.c
@@ -52,7 +52,7 @@  qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 	vaf.va = &va;
 
 	if (!(qedi_dbg_log & QEDI_LOG_WARN))
-		return;
+		goto ret;
 
 	if (likely(qedi) && likely(qedi->pdev))
 		pr_warn("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
@@ -60,6 +60,7 @@  qedi_dbg_warn(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 	else
 		pr_warn("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
 
+ret:
 	va_end(va);
 }
 
@@ -80,7 +81,7 @@  qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 	vaf.va = &va;
 
 	if (!(qedi_dbg_log & QEDI_LOG_NOTICE))
-		return;
+		goto ret;
 
 	if (likely(qedi) && likely(qedi->pdev))
 		pr_notice("[%s]:[%s:%d]:%d: %pV",
@@ -89,6 +90,7 @@  qedi_dbg_notice(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 	else
 		pr_notice("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
 
+ret:
 	va_end(va);
 }
 
@@ -109,7 +111,7 @@  qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 	vaf.va = &va;
 
 	if (!(qedi_dbg_log & level))
-		return;
+		goto ret;
 
 	if (likely(qedi) && likely(qedi->pdev))
 		pr_info("[%s]:[%s:%d]:%d: %pV", dev_name(&qedi->pdev->dev),
@@ -117,6 +119,7 @@  qedi_dbg_info(struct qedi_dbg_ctx *qedi, const char *func, u32 line,
 	else
 		pr_info("[0000:00:00.0]:[%s:%d]: %pV", nfunc, line, &vaf);
 
+ret:
 	va_end(va);
 }