mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Siddarth Gundu <siddarthsgml@gmail.com>
To: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com,
	kuba@kernel.org, pabeni@redhat.com
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org,
	Siddarth Gundu <siddarthsgml@gmail.com>
Subject: [PATCH net v2] fddi: skfp: fix null pointer deferenece in smt.c
Date: Thu,  8 May 2025 02:07:06 +0530	[thread overview]
Message-ID: <20250507203706.42785-1-siddarthsgml@gmail.com> (raw)

In smt_string_swap(), when a closing bracket ']' is encountered
before any opening bracket '[' open_paren would be NULL,
and assigning it to format would lead to a null pointer being
dereferenced in the format++ statement.

Add a check to verify open_paren is non-NULL before assigning
it to format

This issue was reported by Coverity Scan.

Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Siddarth Gundu <siddarthsgml@gmail.com>
---
v2:
 - fix commit message
 - Add mention of Coverity Scan
 - Update Fixes tag to reference initial commit
v1: https://lore.kernel.org/all/20250505091025.27368-1-siddarthsgml@gmail.com/

 drivers/net/fddi/skfp/smt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/fddi/skfp/smt.c b/drivers/net/fddi/skfp/smt.c
index dd15af4e98c2..174f279b89ac 100644
--- a/drivers/net/fddi/skfp/smt.c
+++ b/drivers/net/fddi/skfp/smt.c
@@ -1857,7 +1857,8 @@ static void smt_string_swap(char *data, const char *format, int len)
 			open_paren = format ;
 			break ;
 		case ']' :
-			format = open_paren ;
+			if (open_paren)
+				format = open_paren ;
 			break ;
 		case '1' :
 		case '2' :
-- 
2.43.0


             reply	other threads:[~2025-05-07 20:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 20:37 Siddarth Gundu [this message]
2025-05-09  2:27 ` Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250507203706.42785-1-siddarthsgml@gmail.com \
    --to=siddarthsgml@gmail.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®