public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup()
@ 2026-02-03 23:07 Artem Lytkin
  2026-02-03 23:07 ` [PATCH 2/4] staging: sm750fb: use strcmp() for exact option matching Artem Lytkin
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Artem Lytkin @ 2026-02-03 23:07 UTC (permalink / raw)
  To: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman
  Cc: linux-fbdev, linux-staging, linux-kernel, Artem Lytkin

Replace deprecated strcat() with memcpy() in option parsing. The
destination buffer is allocated with kzalloc (zero-filled) and the
write position is tracked via pointer, making the null-terminator
scan in strcat() redundant and potentially unsafe.

Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index fecd7457e..4c6e84c03 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -1163,7 +1163,7 @@ static int __init lynxfb_setup(char *options)
 		} else if (!strncmp(opt, "dual", strlen("dual"))) {
 			g_dualview = 1;
 		} else {
-			strcat(tmp, opt);
+			memcpy(tmp, opt, strlen(opt));
 			tmp += strlen(opt);
 			if (options)
 				*tmp++ = ':';
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/4] staging: sm750fb: use strcmp() for exact option matching
  2026-02-03 23:07 [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Artem Lytkin
@ 2026-02-03 23:07 ` Artem Lytkin
  2026-02-03 23:07 ` [PATCH 3/4] staging: sm750fb: convert pr_* to dev_* logging in sm750.c Artem Lytkin
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Artem Lytkin @ 2026-02-03 23:07 UTC (permalink / raw)
  To: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman
  Cc: linux-fbdev, linux-staging, linux-kernel, Artem Lytkin

Replace strncmp(opt, "...", strlen("...")) with strcmp() in option
parsing functions. Options from strsep() are complete null-terminated
tokens, so prefix matching via strncmp() could cause false positives
for options like "noaccelXYZ" matching "noaccel".

Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index 4c6e84c03..bd2d4a290 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -937,21 +937,21 @@ static void sm750fb_setup(struct sm750_dev *sm750_dev, char *src)
 		dev_info(&sm750_dev->pdev->dev, "opt=%s\n", opt);
 		dev_info(&sm750_dev->pdev->dev, "src=%s\n", src);
 
-		if (!strncmp(opt, "swap", strlen("swap"))) {
+		if (!strcmp(opt, "swap")) {
 			swap = 1;
-		} else if (!strncmp(opt, "nocrt", strlen("nocrt"))) {
+		} else if (!strcmp(opt, "nocrt")) {
 			sm750_dev->nocrt = 1;
-		} else if (!strncmp(opt, "36bit", strlen("36bit"))) {
+		} else if (!strcmp(opt, "36bit")) {
 			sm750_dev->pnltype = sm750_doubleTFT;
-		} else if (!strncmp(opt, "18bit", strlen("18bit"))) {
+		} else if (!strcmp(opt, "18bit")) {
 			sm750_dev->pnltype = sm750_dualTFT;
-		} else if (!strncmp(opt, "24bit", strlen("24bit"))) {
+		} else if (!strcmp(opt, "24bit")) {
 			sm750_dev->pnltype = sm750_24TFT;
-		} else if (!strncmp(opt, "nohwc0", strlen("nohwc0"))) {
+		} else if (!strcmp(opt, "nohwc0")) {
 			g_hwcursor &= ~0x1;
-		} else if (!strncmp(opt, "nohwc1", strlen("nohwc1"))) {
+		} else if (!strcmp(opt, "nohwc1")) {
 			g_hwcursor &= ~0x2;
-		} else if (!strncmp(opt, "nohwc", strlen("nohwc"))) {
+		} else if (!strcmp(opt, "nohwc")) {
 			g_hwcursor = 0;
 		} else {
 			if (!g_fbmode[0]) {
@@ -1156,11 +1156,11 @@ static int __init lynxfb_setup(char *options)
 	 */
 	while ((opt = strsep(&options, ":")) != NULL) {
 		/* options that mean for any lynx chips are configured here */
-		if (!strncmp(opt, "noaccel", strlen("noaccel"))) {
+		if (!strcmp(opt, "noaccel")) {
 			g_noaccel = 1;
-		} else if (!strncmp(opt, "nomtrr", strlen("nomtrr"))) {
+		} else if (!strcmp(opt, "nomtrr")) {
 			g_nomtrr = 1;
-		} else if (!strncmp(opt, "dual", strlen("dual"))) {
+		} else if (!strcmp(opt, "dual")) {
 			g_dualview = 1;
 		} else {
 			memcpy(tmp, opt, strlen(opt));
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/4] staging: sm750fb: convert pr_* to dev_* logging in sm750.c
  2026-02-03 23:07 [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Artem Lytkin
  2026-02-03 23:07 ` [PATCH 2/4] staging: sm750fb: use strcmp() for exact option matching Artem Lytkin
@ 2026-02-03 23:07 ` Artem Lytkin
  2026-02-04  9:54   ` Dan Carpenter
  2026-02-03 23:07 ` [PATCH 4/4] staging: sm750fb: convert pr_* to dev_* logging in sm750_hw.c Artem Lytkin
  2026-02-04  9:51 ` [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Dan Carpenter
  3 siblings, 1 reply; 7+ messages in thread
From: Artem Lytkin @ 2026-02-03 23:07 UTC (permalink / raw)
  To: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman
  Cc: linux-fbdev, linux-staging, linux-kernel, Artem Lytkin

Convert pr_info/pr_err/pr_debug/pr_warn calls to their dev_*
equivalents in functions where device context is available via
info->device or par->dev->pdev->dev. This adds device identification
to log messages, improving debuggability in multi-device systems.

Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
---
 drivers/staging/sm750fb/sm750.c | 107 ++++++++++++++++----------------
 1 file changed, 54 insertions(+), 53 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
index bd2d4a290..247c58556 100644
--- a/drivers/staging/sm750fb/sm750.c
+++ b/drivers/staging/sm750fb/sm750.c
@@ -375,7 +375,7 @@ static int lynxfb_ops_set_par(struct fb_info *info)
 	line_length = var->xres_virtual * var->bits_per_pixel / 8;
 	line_length = ALIGN(line_length, crtc->line_pad);
 	fix->line_length = line_length;
-	pr_info("fix->line_length = %d\n", fix->line_length);
+	dev_info(info->device, "fix->line_length = %d\n", fix->line_length);
 
 	/*
 	 * var->red,green,blue,transp are need to be set by driver
@@ -389,7 +389,8 @@ static int lynxfb_ops_set_par(struct fb_info *info)
 	var->accel_flags = 0;/*FB_ACCELF_TEXT;*/
 
 	if (ret) {
-		pr_err("bpp %d not supported\n", var->bits_per_pixel);
+		dev_err(info->device, "bpp %d not supported\n",
+			var->bits_per_pixel);
 		return ret;
 	}
 	ret = hw_sm750_crtc_set_mode(crtc, var, fix);
@@ -485,15 +486,16 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
 	par = info->par;
 	crtc = &par->crtc;
 
-	pr_debug("check var:%dx%d-%d\n",
-		 var->xres,
-		 var->yres,
-		 var->bits_per_pixel);
+	dev_dbg(info->device, "check var:%dx%d-%d\n",
+		var->xres,
+		var->yres,
+		var->bits_per_pixel);
 
 	ret = lynxfb_set_color_offsets(info);
 
 	if (ret) {
-		pr_err("bpp %d not supported\n", var->bits_per_pixel);
+		dev_err(info->device, "bpp %d not supported\n",
+			var->bits_per_pixel);
 		return ret;
 	}
 
@@ -508,7 +510,7 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
 	request = ALIGN(request, crtc->line_pad);
 	request = request * var->yres_virtual;
 	if (crtc->vidmem_size < request) {
-		pr_err("not enough video memory for mode\n");
+		dev_err(info->device, "not enough video memory for mode\n");
 		return -ENOMEM;
 	}
 
@@ -533,7 +535,7 @@ static int lynxfb_ops_setcolreg(unsigned int regno,
 	ret = 0;
 
 	if (regno > 256) {
-		pr_err("regno = %d\n", regno);
+		dev_err(info->device, "regno = %d\n", regno);
 		return -EINVAL;
 	}
 
@@ -580,10 +582,10 @@ static int lynxfb_ops_blank(int blank, struct fb_info *info)
 	struct lynxfb_par *par;
 	struct lynxfb_output *output;
 
-	pr_debug("blank = %d.\n", blank);
 	par = info->par;
 	output = &par->output;
 	sm750_dev = par->dev;
+	dev_dbg(info->device, "blank = %d.\n", blank);
 
 	if (sm750_dev->revid == SM750LE_REVISION_ID)
 		return hw_sm750le_set_blank(output, blank);
@@ -625,7 +627,7 @@ static int sm750fb_set_drv(struct lynxfb_par *par)
 		crtc->channel = sm750_primary;
 		crtc->o_screen = 0;
 		crtc->v_screen = sm750_dev->pvMem;
-		pr_info("use simul primary mode\n");
+		dev_info(&par->dev->pdev->dev, "use simul primary mode\n");
 		break;
 	case sm750_simul_sec:
 		output->paths = sm750_pnc;
@@ -767,7 +769,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 	crtc->cursor.mmio = sm750_dev->pvReg +
 		0x800f0 + (int)crtc->channel * 0x140;
 
-	pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio);
+	dev_info(info->device, "crtc->cursor.mmio = %p\n", crtc->cursor.mmio);
 	crtc->cursor.max_h = 64;
 	crtc->cursor.max_w = 64;
 	crtc->cursor.size = crtc->cursor.max_h * crtc->cursor.max_w * 2 / 8;
@@ -802,45 +804,42 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 				   pdb[i], cdb[i], NULL, 8);
 
 		if (ret == 1) {
-			pr_info("success! use specified mode:%s in %s\n",
-				g_fbmode[index],
-				mdb_desc[i]);
+			dev_info(info->device,
+				 "success! use specified mode:%s in %s\n",
+				 g_fbmode[index],
+				 mdb_desc[i]);
 			break;
 		} else if (ret == 2) {
-			pr_warn("use specified mode:%s in %s,with an ignored refresh rate\n",
-				g_fbmode[index],
-				mdb_desc[i]);
+			dev_warn(info->device,
+				 "use specified mode:%s in %s,with an ignored refresh rate\n",
+				 g_fbmode[index],
+				 mdb_desc[i]);
 			break;
 		} else if (ret == 3) {
-			pr_warn("wanna use default mode\n");
+			dev_warn(info->device, "wanna use default mode\n");
 			/*break;*/
 		} else if (ret == 4) {
-			pr_warn("fall back to any valid mode\n");
+			dev_warn(info->device,
+				 "fall back to any valid mode\n");
 		} else {
-			pr_warn("ret = %d,fb_find_mode failed,with %s\n",
-				ret,
-				mdb_desc[i]);
+			dev_warn(info->device,
+				 "ret = %d,fb_find_mode failed,with %s\n",
+				 ret,
+				 mdb_desc[i]);
 		}
 	}
 
 	/* some member of info->var had been set by fb_find_mode */
 
-	pr_info("Member of info->var is :\n"
-		"xres=%d\n"
-		"yres=%d\n"
-		"xres_virtual=%d\n"
-		"yres_virtual=%d\n"
-		"xoffset=%d\n"
-		"yoffset=%d\n"
-		"bits_per_pixel=%d\n"
-		" ...\n",
-		var->xres,
-		var->yres,
-		var->xres_virtual,
-		var->yres_virtual,
-		var->xoffset,
-		var->yoffset,
-		var->bits_per_pixel);
+	dev_info(info->device,
+		 "Member of info->var is :\nxres=%d\nyres=%d\nxres_virtual=%d\nyres_virtual=%d\nxoffset=%d\nyoffset=%d\nbits_per_pixel=%d\n ...\n",
+		 var->xres,
+		 var->yres,
+		 var->xres_virtual,
+		 var->yres_virtual,
+		 var->xoffset,
+		 var->yoffset,
+		 var->bits_per_pixel);
 
 	/* set par */
 	par->info = info;
@@ -851,7 +850,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 
 	info->pseudo_palette = &par->pseudo_palette[0];
 	info->screen_base = crtc->v_screen;
-	pr_debug("screen_base vaddr = %p\n", info->screen_base);
+	dev_dbg(info->device, "screen_base vaddr = %p\n", info->screen_base);
 	info->screen_size = line_length * var->yres_virtual;
 
 	/* set info->fix */
@@ -865,7 +864,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 	strscpy(fix->id, fixId[index], sizeof(fix->id));
 
 	fix->smem_start = crtc->o_screen + sm750_dev->vidmem_start;
-	pr_info("fix->smem_start = %lx\n", fix->smem_start);
+	dev_info(info->device, "fix->smem_start = %lx\n", fix->smem_start);
 	/*
 	 * according to mmap experiment from user space application,
 	 * fix->mmio_len should not larger than virtual size
@@ -874,13 +873,13 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 	 * data into the bound over virtual size
 	 */
 	fix->smem_len = crtc->vidmem_size;
-	pr_info("fix->smem_len = %x\n", fix->smem_len);
+	dev_info(info->device, "fix->smem_len = %x\n", fix->smem_len);
 	info->screen_size = fix->smem_len;
 	fix->line_length = line_length;
 	fix->mmio_start = sm750_dev->vidreg_start;
-	pr_info("fix->mmio_start = %lx\n", fix->mmio_start);
+	dev_info(info->device, "fix->mmio_start = %lx\n", fix->mmio_start);
 	fix->mmio_len = sm750_dev->vidreg_size;
-	pr_info("fix->mmio_len = %x\n", fix->mmio_len);
+	dev_info(info->device, "fix->mmio_len = %x\n", fix->mmio_len);
 
 	lynxfb_set_visual_mode(info);
 
@@ -889,21 +888,23 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
 	var->accel_flags = 0;
 	var->vmode = FB_VMODE_NONINTERLACED;
 
-	pr_debug("#1 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
-		 info->cmap.start, info->cmap.len,
-		 info->cmap.red, info->cmap.green, info->cmap.blue,
-		 info->cmap.transp);
+	dev_dbg(info->device,
+		"#1 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
+		info->cmap.start, info->cmap.len,
+		info->cmap.red, info->cmap.green, info->cmap.blue,
+		info->cmap.transp);
 
 	ret = fb_alloc_cmap(&info->cmap, 256, 0);
 	if (ret < 0) {
-		pr_err("Could not allocate memory for cmap.\n");
+		dev_err(info->device, "Could not allocate memory for cmap.\n");
 		goto exit;
 	}
 
-	pr_debug("#2 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
-		 info->cmap.start, info->cmap.len,
-		 info->cmap.red, info->cmap.green, info->cmap.blue,
-		 info->cmap.transp);
+	dev_dbg(info->device,
+		"#2 show info->cmap :\nstart=%d,len=%d,red=%p,green=%p,blue=%p,transp=%p\n",
+		info->cmap.start, info->cmap.len,
+		info->cmap.red, info->cmap.green, info->cmap.blue,
+		info->cmap.transp);
 
 exit:
 	lynxfb_ops_check_var(var, info);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 4/4] staging: sm750fb: convert pr_* to dev_* logging in sm750_hw.c
  2026-02-03 23:07 [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Artem Lytkin
  2026-02-03 23:07 ` [PATCH 2/4] staging: sm750fb: use strcmp() for exact option matching Artem Lytkin
  2026-02-03 23:07 ` [PATCH 3/4] staging: sm750fb: convert pr_* to dev_* logging in sm750.c Artem Lytkin
@ 2026-02-03 23:07 ` Artem Lytkin
  2026-02-04  9:55   ` Dan Carpenter
  2026-02-04  9:51 ` [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Dan Carpenter
  3 siblings, 1 reply; 7+ messages in thread
From: Artem Lytkin @ 2026-02-03 23:07 UTC (permalink / raw)
  To: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman
  Cc: linux-fbdev, linux-staging, linux-kernel, Artem Lytkin

Convert pr_info/pr_err calls to dev_info/dev_err in hw_sm750_map()
and hw_sm750_inithw() where struct pci_dev *pdev is available as
a function parameter. Functions without direct device pointer access
are left unchanged to avoid unnecessary signature changes.

Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
---
 drivers/staging/sm750fb/sm750_hw.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
index ce46f240c..60f9f7135 100644
--- a/drivers/staging/sm750fb/sm750_hw.c
+++ b/drivers/staging/sm750fb/sm750_hw.c
@@ -34,7 +34,7 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 	sm750_dev->vidreg_start = pci_resource_start(pdev, 1);
 	sm750_dev->vidreg_size = SZ_2M;
 
-	pr_info("mmio phyAddr = %lx\n", sm750_dev->vidreg_start);
+	dev_info(&pdev->dev, "mmio phyAddr = %lx\n", sm750_dev->vidreg_start);
 
 	/*
 	 * reserve the vidreg space of smi adaptor
@@ -44,7 +44,7 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 	 */
 	ret = pci_request_region(pdev, 1, "sm750fb");
 	if (ret) {
-		pr_err("Can not request PCI regions.\n");
+		dev_err(&pdev->dev, "Can not request PCI regions.\n");
 		goto exit;
 	}
 
@@ -52,11 +52,11 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 	sm750_dev->pvReg =
 		ioremap(sm750_dev->vidreg_start, sm750_dev->vidreg_size);
 	if (!sm750_dev->pvReg) {
-		pr_err("mmio failed\n");
+		dev_err(&pdev->dev, "mmio failed\n");
 		ret = -EFAULT;
 		goto exit;
 	}
-	pr_info("mmio virtual addr = %p\n", sm750_dev->pvReg);
+	dev_info(&pdev->dev, "mmio virtual addr = %p\n", sm750_dev->pvReg);
 
 	sm750_dev->accel.dpr_base = sm750_dev->pvReg + DE_BASE_ADDR_TYPE1;
 	sm750_dev->accel.dp_port_base = sm750_dev->pvReg + DE_PORT_ADDR_TYPE1;
@@ -72,19 +72,19 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 	 * @ddk750_get_vm_size function can be safe.
 	 */
 	sm750_dev->vidmem_size = ddk750_get_vm_size();
-	pr_info("video memory phyAddr = %lx, size = %u bytes\n",
-		sm750_dev->vidmem_start, sm750_dev->vidmem_size);
+	dev_info(&pdev->dev, "video memory phyAddr = %lx, size = %u bytes\n",
+		 sm750_dev->vidmem_start, sm750_dev->vidmem_size);
 
 	/* reserve the vidmem space of smi adaptor */
 	sm750_dev->pvMem =
 		ioremap_wc(sm750_dev->vidmem_start, sm750_dev->vidmem_size);
 	if (!sm750_dev->pvMem) {
 		iounmap(sm750_dev->pvReg);
-		pr_err("Map video memory failed\n");
+		dev_err(&pdev->dev, "Map video memory failed\n");
 		ret = -EFAULT;
 		goto exit;
 	}
-	pr_info("video memory vaddr = %p\n", sm750_dev->pvMem);
+	dev_info(&pdev->dev, "video memory vaddr = %p\n", sm750_dev->pvMem);
 exit:
 	return ret;
 }
@@ -163,11 +163,11 @@ int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
 			 * The following register values for CH7301 are from
 			 * Chrontel app note and our experiment.
 			 */
-			pr_info("yes,CH7301 DVI chip found\n");
+			dev_info(&pdev->dev, "CH7301 DVI chip found\n");
 			sm750_sw_i2c_write_reg(0xec, 0x1d, 0x16);
 			sm750_sw_i2c_write_reg(0xec, 0x21, 0x9);
 			sm750_sw_i2c_write_reg(0xec, 0x49, 0xC0);
-			pr_info("okay,CH7301 DVI chip setup done\n");
+			dev_info(&pdev->dev, "CH7301 DVI chip setup done\n");
 		}
 	}
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup()
  2026-02-03 23:07 [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Artem Lytkin
                   ` (2 preceding siblings ...)
  2026-02-03 23:07 ` [PATCH 4/4] staging: sm750fb: convert pr_* to dev_* logging in sm750_hw.c Artem Lytkin
@ 2026-02-04  9:51 ` Dan Carpenter
  3 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2026-02-04  9:51 UTC (permalink / raw)
  To: Artem Lytkin
  Cc: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman, linux-fbdev,
	linux-staging, linux-kernel

On Tue, Feb 03, 2026 at 11:07:55PM +0000, Artem Lytkin wrote:
> Replace deprecated strcat() with memcpy() in option parsing. The
> destination buffer is allocated with kzalloc (zero-filled) and the
> write position is tracked via pointer, making the null-terminator
> scan in strcat() redundant and potentially unsafe.
> 
> Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
> ---
>  drivers/staging/sm750fb/sm750.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index fecd7457e..4c6e84c03 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -1163,7 +1163,7 @@ static int __init lynxfb_setup(char *options)
>  		} else if (!strncmp(opt, "dual", strlen("dual"))) {
>  			g_dualview = 1;
>  		} else {
> -			strcat(tmp, opt);
> +			memcpy(tmp, opt, strlen(opt));

This has exactly the same security issues as the original code.

regards,
dan carpenter

>  			tmp += strlen(opt);
>  			if (options)
>  				*tmp++ = ':';
> -- 
> 2.43.0
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/4] staging: sm750fb: convert pr_* to dev_* logging in sm750.c
  2026-02-03 23:07 ` [PATCH 3/4] staging: sm750fb: convert pr_* to dev_* logging in sm750.c Artem Lytkin
@ 2026-02-04  9:54   ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2026-02-04  9:54 UTC (permalink / raw)
  To: Artem Lytkin
  Cc: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman, linux-fbdev,
	linux-staging, linux-kernel

On Tue, Feb 03, 2026 at 11:07:57PM +0000, Artem Lytkin wrote:
> Convert pr_info/pr_err/pr_debug/pr_warn calls to their dev_*
> equivalents in functions where device context is available via
> info->device or par->dev->pdev->dev. This adds device identification
> to log messages, improving debuggability in multi-device systems.
> 
> Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
> ---
>  drivers/staging/sm750fb/sm750.c | 107 ++++++++++++++++----------------
>  1 file changed, 54 insertions(+), 53 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c
> index bd2d4a290..247c58556 100644
> --- a/drivers/staging/sm750fb/sm750.c
> +++ b/drivers/staging/sm750fb/sm750.c
> @@ -375,7 +375,7 @@ static int lynxfb_ops_set_par(struct fb_info *info)
>  	line_length = var->xres_virtual * var->bits_per_pixel / 8;
>  	line_length = ALIGN(line_length, crtc->line_pad);
>  	fix->line_length = line_length;
> -	pr_info("fix->line_length = %d\n", fix->line_length);
> +	dev_info(info->device, "fix->line_length = %d\n", fix->line_length);

Just delete this sort of thing.

>  
>  	/*
>  	 * var->red,green,blue,transp are need to be set by driver
> @@ -389,7 +389,8 @@ static int lynxfb_ops_set_par(struct fb_info *info)
>  	var->accel_flags = 0;/*FB_ACCELF_TEXT;*/
>  
>  	if (ret) {
> -		pr_err("bpp %d not supported\n", var->bits_per_pixel);
> +		dev_err(info->device, "bpp %d not supported\n",
> +			var->bits_per_pixel);
>  		return ret;
>  	}
>  	ret = hw_sm750_crtc_set_mode(crtc, var, fix);
> @@ -485,15 +486,16 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
>  	par = info->par;
>  	crtc = &par->crtc;
>  
> -	pr_debug("check var:%dx%d-%d\n",
> -		 var->xres,
> -		 var->yres,
> -		 var->bits_per_pixel);
> +	dev_dbg(info->device, "check var:%dx%d-%d\n",
> +		var->xres,
> +		var->yres,
> +		var->bits_per_pixel);
>  
>  	ret = lynxfb_set_color_offsets(info);
>  
>  	if (ret) {
> -		pr_err("bpp %d not supported\n", var->bits_per_pixel);
> +		dev_err(info->device, "bpp %d not supported\n",
> +			var->bits_per_pixel);
>  		return ret;
>  	}
>  
> @@ -508,7 +510,7 @@ static int lynxfb_ops_check_var(struct fb_var_screeninfo *var,
>  	request = ALIGN(request, crtc->line_pad);
>  	request = request * var->yres_virtual;
>  	if (crtc->vidmem_size < request) {
> -		pr_err("not enough video memory for mode\n");
> +		dev_err(info->device, "not enough video memory for mode\n");
>  		return -ENOMEM;
>  	}
>  
> @@ -533,7 +535,7 @@ static int lynxfb_ops_setcolreg(unsigned int regno,
>  	ret = 0;
>  
>  	if (regno > 256) {
> -		pr_err("regno = %d\n", regno);
> +		dev_err(info->device, "regno = %d\n", regno);
>  		return -EINVAL;
>  	}
>  
> @@ -580,10 +582,10 @@ static int lynxfb_ops_blank(int blank, struct fb_info *info)
>  	struct lynxfb_par *par;
>  	struct lynxfb_output *output;
>  
> -	pr_debug("blank = %d.\n", blank);
>  	par = info->par;
>  	output = &par->output;
>  	sm750_dev = par->dev;
> +	dev_dbg(info->device, "blank = %d.\n", blank);
>  
>  	if (sm750_dev->revid == SM750LE_REVISION_ID)
>  		return hw_sm750le_set_blank(output, blank);
> @@ -625,7 +627,7 @@ static int sm750fb_set_drv(struct lynxfb_par *par)
>  		crtc->channel = sm750_primary;
>  		crtc->o_screen = 0;
>  		crtc->v_screen = sm750_dev->pvMem;
> -		pr_info("use simul primary mode\n");
> +		dev_info(&par->dev->pdev->dev, "use simul primary mode\n");

Is this useful?

>  		break;
>  	case sm750_simul_sec:
>  		output->paths = sm750_pnc;
> @@ -767,7 +769,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index)
>  	crtc->cursor.mmio = sm750_dev->pvReg +
>  		0x800f0 + (int)crtc->channel * 0x140;
>  
> -	pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio);
> +	dev_info(info->device, "crtc->cursor.mmio = %p\n", crtc->cursor.mmio);

Delete.  Okay, follow the same pattern and delete the debug
code which is printed as _info.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 4/4] staging: sm750fb: convert pr_* to dev_* logging in sm750_hw.c
  2026-02-03 23:07 ` [PATCH 4/4] staging: sm750fb: convert pr_* to dev_* logging in sm750_hw.c Artem Lytkin
@ 2026-02-04  9:55   ` Dan Carpenter
  0 siblings, 0 replies; 7+ messages in thread
From: Dan Carpenter @ 2026-02-04  9:55 UTC (permalink / raw)
  To: Artem Lytkin
  Cc: Sudip Mukherjee, Teddy Wang, Greg Kroah-Hartman, linux-fbdev,
	linux-staging, linux-kernel

On Tue, Feb 03, 2026 at 11:07:58PM +0000, Artem Lytkin wrote:
> Convert pr_info/pr_err calls to dev_info/dev_err in hw_sm750_map()
> and hw_sm750_inithw() where struct pci_dev *pdev is available as
> a function parameter. Functions without direct device pointer access
> are left unchanged to avoid unnecessary signature changes.
> 
> Signed-off-by: Artem Lytkin <iprintercanon@gmail.com>
> ---
>  drivers/staging/sm750fb/sm750_hw.c | 20 ++++++++++----------
>  1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c
> index ce46f240c..60f9f7135 100644
> --- a/drivers/staging/sm750fb/sm750_hw.c
> +++ b/drivers/staging/sm750fb/sm750_hw.c
> @@ -34,7 +34,7 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev)
>  	sm750_dev->vidreg_start = pci_resource_start(pdev, 1);
>  	sm750_dev->vidreg_size = SZ_2M;
>  
> -	pr_info("mmio phyAddr = %lx\n", sm750_dev->vidreg_start);
> +	dev_info(&pdev->dev, "mmio phyAddr = %lx\n", sm750_dev->vidreg_start);
>  

Same.

regards,
dan carpenter


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-02-04  9:55 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-03 23:07 [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Artem Lytkin
2026-02-03 23:07 ` [PATCH 2/4] staging: sm750fb: use strcmp() for exact option matching Artem Lytkin
2026-02-03 23:07 ` [PATCH 3/4] staging: sm750fb: convert pr_* to dev_* logging in sm750.c Artem Lytkin
2026-02-04  9:54   ` Dan Carpenter
2026-02-03 23:07 ` [PATCH 4/4] staging: sm750fb: convert pr_* to dev_* logging in sm750_hw.c Artem Lytkin
2026-02-04  9:55   ` Dan Carpenter
2026-02-04  9:51 ` [PATCH 1/4] staging: sm750fb: replace strcat() with memcpy() in lynxfb_setup() Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox