Skip to contentSkip to conversation

Fix k.alloc switched arguments

PATCH In review Joe Perches 4 participants 9 messages Oct 31, 2010 – Nov 2, 2010

Subsystems (7)
DRM drivers SCSI DRM misc Staging +3 more subsystems
lore
Share & tools
lore

Joe Perches

author maintainer
#0 lore raw

cover Fix k.alloc switched arguments

Joe Perches (4):
drivers/gpu/drm/vmwgfx: Fix k.alloc switched arguments drivers/scsi/pmcraid.c: Fix k.alloc switched arguments drivers/staging/udlfb/udlfb.c: Fix k.alloc switched arguments scripts/checkpatch.pl: Add check for k.alloc GFP as first argument

 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c     |    2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c |    2 +-
 drivers/scsi/pmcraid.c                  |    4 ++--
 drivers/staging/udlfb/udlfb.c           |    2 +-
 scripts/checkpatch.pl                   |    5 +++++
 5 files changed, 10 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.3.1.g432b3.dirty
author maintainer
#1 lore raw

PATCH 1/4 drivers/gpu/drm/vmwgfx: Fix k.alloc switched arguments

---
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c     |    2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +1 -1
index a01c47d..29113c9 100644
@@ -557,7 +557,7 @@ int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv)
 		return -EINVAL;
 	}
 
-	dev_priv->ldu_priv = kmalloc(GFP_KERNEL, sizeof(*dev_priv->ldu_priv));
+	dev_priv->ldu_priv = kmalloc(sizeof(*dev_priv->ldu_priv), GFP_KERNEL);
 
 	if (!dev_priv->ldu_priv)
 		return -ENOMEM;
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +1 -1
index df2036e..f1a52f9 100644
@@ -585,7 +585,7 @@ int vmw_overlay_init(struct vmw_private *dev_priv)
 		return -ENOSYS;
 	}
 
-	overlay = kmalloc(GFP_KERNEL, sizeof(*overlay));
+	overlay = kmalloc(sizeof(*overlay), GFP_KERNEL);
 	if (!overlay)
 		return -ENOMEM;
 
Signature · 1 line
1.7.3.1.g432b3.dirty
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] drivers/gpu/drm/vmwgfx: Fix k.alloc switched arguments

Quoted 33 lines · Joe Perches

---
 drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c     |    2 +- drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c |    2 +-

 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +1 -1
index a01c47d..29113c9 100644
@@ -557,7 +557,7 @@ int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv)
                return -EINVAL;
        }
 
-       dev_priv->ldu_priv = kmalloc(GFP_KERNEL, sizeof(*dev_priv->ldu_priv));
+       dev_priv->ldu_priv = kmalloc(sizeof(*dev_priv->ldu_priv), GFP_KERNEL);
 
        if (!dev_priv->ldu_priv)
                return -ENOMEM;
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +1 -2
index df2036e..f1a52f9 100644
@@ -585,7 +585,7 @@ int vmw_overlay_init(struct vmw_private *dev_priv)
                return -ENOSYS;
        }
 
-       overlay = kmalloc(GFP_KERNEL, sizeof(*overlay));
+       overlay = kmalloc(sizeof(*overlay), GFP_KERNEL);
        if (!overlay)
                return -ENOMEM;
 
--
Quoted 1 line

1.7.3.1.g432b3.dirty

Oh! That's a bad one.

Reviewed-by
#3 lore raw

Re: [PATCH 1/4] drivers/gpu/drm/vmwgfx: Fix k.alloc switched arguments

Quoted 34 lines · Matt Turner
Quoted 32 lines · Joe Perches
---
  drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c     |    2 +-
  drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c |    2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/vmwgfx/vmwgfx_ldu.c +1 -1
index a01c47d..29113c9 100644
@@ -557,7 +557,7 @@ int vmw_kms_init_legacy_display_system(struct vmw_private *dev_priv)
                return -EINVAL;
        }
 
-       dev_priv->ldu_priv = kmalloc(GFP_KERNEL, sizeof(*dev_priv->ldu_priv));
+       dev_priv->ldu_priv = kmalloc(sizeof(*dev_priv->ldu_priv), GFP_KERNEL);
 
        if (!dev_priv->ldu_priv)
                return -ENOMEM;
drivers/gpu/drm/vmwgfx/vmwgfx_overlay.c +1 -1
index df2036e..f1a52f9 100644
@@ -585,7 +585,7 @@ int vmw_overlay_init(struct vmw_private *dev_priv)
                return -ENOSYS;
        }
 
-       overlay = kmalloc(GFP_KERNEL, sizeof(*overlay));
+       overlay = kmalloc(sizeof(*overlay), GFP_KERNEL);
        if (!overlay)
                return -ENOMEM;
 
Quoted 5 lines
Quoted 3 lines

--
1.7.3.1.g432b3.dirty

Oh! That's a bad one.

Indeed.

Quoted 2 lines
Quoted 5 lines

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel

author maintainer
#4 lore raw

PATCH 2/4 drivers/scsi/pmcraid.c: Fix k.alloc switched arguments

In reply to Joe Perches

And a typo fix of faile to failed.

---
 drivers/scsi/pmcraid.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/pmcraid.c +2 -2
index 4b87657..e5a694a 100644
@@ -4094,10 +4094,10 @@ static long pmcraid_chr_ioctl(
 	struct pmcraid_ioctl_header *hdr = NULL;
 	int retval = -ENOTTY;
 
-	hdr = kmalloc(GFP_KERNEL, sizeof(struct pmcraid_ioctl_header));
+	hdr = kmalloc(sizeof(struct pmcraid_ioctl_header), GFP_KERNEL);
 
 	if (!hdr) {
-		pmcraid_err("faile to allocate memory for ioctl header\n");
+		pmcraid_err("failed to allocate memory for ioctl header\n");
 		return -ENOMEM;
 	}
 
Signature · 1 line
1.7.3.1.g432b3.dirty
author maintainer
#5 lore raw

PATCH RESEND 2/4 drivers/scsi/pmcraid.c: Fix k.alloc switched arguments

In reply to Joe Perches

And a typo fix of faile to failed.

---
 drivers/scsi/pmcraid.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/pmcraid.c +2 -2
index 4b87657..e5a694a 100644
@@ -4094,10 +4094,10 @@ static long pmcraid_chr_ioctl(
 	struct pmcraid_ioctl_header *hdr = NULL;
 	int retval = -ENOTTY;
 
-	hdr = kmalloc(GFP_KERNEL, sizeof(struct pmcraid_ioctl_header));
+	hdr = kmalloc(sizeof(struct pmcraid_ioctl_header), GFP_KERNEL);
 
 	if (!hdr) {
-		pmcraid_err("faile to allocate memory for ioctl header\n");
+		pmcraid_err("failed to allocate memory for ioctl header\n");
 		return -ENOMEM;
 	}
 
Signature · 7 lines
1.7.3.1.g432b3.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
author maintainer
#6 lore raw

PATCH 3/4 drivers/staging/udlfb/udlfb.c: Fix k.alloc switched arguments

In reply to Joe Perches
---
 drivers/staging/udlfb/udlfb.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/staging/udlfb/udlfb.c +1 -1
index 5969e84..fed2510 100644
@@ -887,7 +887,7 @@ static int dlfb_ops_open(struct fb_info *info, int user)
 
 		struct fb_deferred_io *fbdefio;
 
-		fbdefio = kmalloc(GFP_KERNEL, sizeof(struct fb_deferred_io));
+		fbdefio = kmalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
 
 		if (fbdefio) {
 			fbdefio->delay = DL_DEFIO_WRITE_DELAY;
Signature · 1 line
1.7.3.1.g432b3.dirty
author maintainer
#7 lore raw

PATCH 4/4 scripts/checkpatch.pl: Add check for k.alloc GFP as first argument

In reply to Joe Perches
---
 scripts/checkpatch.pl |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
scripts/checkpatch.pl +5 -0
index 90b54d4..114f667 100755
@@ -2789,6 +2789,11 @@ sub process {
 			WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
 		}
 
+# check for k.alloc GFP in wrong location
+		if ($line =~ /\bk[czm]alloc\s*\(\s*\(?\s*GFP_/) {
+			ERROR("alloc has GFP_<level> as last argument\n" . $herecurr);
+		}
+
 # check for gcc specific __FUNCTION__
 		if ($line =~ /__FUNCTION__/) {
 			WARN("__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
Signature · 1 line
1.7.3.1.g432b3.dirty
#8 lore raw

Re: [PATCH 4/4] scripts/checkpatch.pl: Add check for k.alloc GFP as first argument

Quoted 10 lines · Joe Perches
---
 scripts/checkpatch.pl |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
scripts/checkpatch.pl +0 -0
index 90b54d4..114f667 100755

scripts/checkpatch.pl sub process { · line 2793

Quoted 5 lines
scripts/checkpatch.pl +2 -0
@@ -2789,6 +2789,11 @@ sub process {
 			WARN("unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
 		}
 
+# check for k.alloc GFP in wrong location
+		if ($line =~ /\bk[czm]alloc\s*\(\s*\(?\s*GFP_/) {

Just off the top of my head, but shouldn't this check for \s*_*GFP_ in order to catch things like __GFP_ZERO as well?
And what about functions like kmalloc_node()/vmalloc_node() which may also have this problem?

Quoted 7 lines
scripts/checkpatch.pl +3 -0
+			ERROR("alloc has GFP_<level> as last argument\n" . $herecurr);
+		}
+
 # check for gcc specific __FUNCTION__
 		if ($line =~ /__FUNCTION__/) {
 			WARN("__func__ should be used instead of gcc specific __FUNCTION__\n"  . $herecurr);
Signature · 3 lines
Jesper Juhl <[email protected]>             http://www.chaosbits.net/
Plain text mails only, please      http://www.expita.com/nomime.html
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html