Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1301709 > unrolled thread

[PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path

Started byPeter Senna Tschudin <peter.senna@collabora.com>
First post2016-01-05 18:00 +0100
Last post2016-01-07 16:20 +0100
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path Peter Senna Tschudin <peter.senna@collabora.com> - 2016-01-05 18:00 +0100
    Re: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix  error path Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> - 2016-01-06 19:30 +0100
      Re: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix  error path Peter Senna Tschudin <peter.senna@collabora.com> - 2016-01-07 16:20 +0100

#1301709 — [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path

FromPeter Senna Tschudin <peter.senna@collabora.com>
Date2016-01-05 18:00 +0100
Subject[PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path
Message-ID<qND7I-5u9-3@gated-at.bofh.it>
From: Peter Senna Tschudin <peter.senna@gmail.com>

This patch remove four calls to dev_err() from sisusb_probe() as
reporting memory allocation failures is redundant:

 - Remove a call to dev_err() that was reporting unsuccesful call to
   kzalloc().

 - Remove two calls to dev_err() that were reporting unsuccesful calls
   to kmalloc().

 - Remove a call to dev_err() that was reporting unsuccesful call to
   kmalloc(), and replace it by code that clean up previously allocated
   resources and abort the probe with -ENOMEM. Before this modification
   sisusb->SiS_Pr could be dereferenced even it was null.

Signed-off-by: Peter Senna Tschudin <peter.senna@collabora.com>
---
Tested by compilation only.

 drivers/usb/misc/sisusbvga/sisusb.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index 6cce4fb..875e365 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3040,10 +3040,9 @@ static int sisusb_probe(struct usb_interface *intf,
 
 	/* Allocate memory for our private */
 	sisusb = kzalloc(sizeof(*sisusb), GFP_KERNEL);
-	if (!sisusb) {
-		dev_err(&dev->dev, "Failed to allocate memory for private data\n");
+	if (!sisusb)
 		return -ENOMEM;
-	}
+
 	kref_init(&sisusb->kref);
 
 	mutex_init(&(sisusb->lock));
@@ -3070,7 +3069,6 @@ static int sisusb_probe(struct usb_interface *intf,
 	sisusb->ibufsize = SISUSB_IBUF_SIZE;
 	sisusb->ibuf = kmalloc(SISUSB_IBUF_SIZE, GFP_KERNEL);
 	if (!sisusb->ibuf) {
-		dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for input buffer");
 		retval = -ENOMEM;
 		goto error_2;
 	}
@@ -3081,7 +3079,6 @@ static int sisusb_probe(struct usb_interface *intf,
 		sisusb->obuf[i] = kmalloc(SISUSB_OBUF_SIZE, GFP_KERNEL);
 		if (!sisusb->obuf[i]) {
 			if (i == 0) {
-				dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate memory for output buffer\n");
 				retval = -ENOMEM;
 				goto error_3;
 			}
@@ -3119,7 +3116,8 @@ static int sisusb_probe(struct usb_interface *intf,
 	/* Allocate our SiS_Pr */
 	sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL);
 	if (!sisusb->SiS_Pr) {
-		dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate SiS_Pr\n");
+		retval = -ENOMEM;
+		goto error_4;
 	}
 #endif
 
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1302959 — Re: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path

FromSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Date2016-01-06 19:30 +0100
SubjectRe: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path
Message-ID<qO10m-4M5-7@gated-at.bofh.it>
In reply to#1301709
Hello.

On 1/5/2016 7:54 PM, Peter Senna Tschudin wrote:

> From: Peter Senna Tschudin <peter.senna@gmail.com>
>
> This patch remove four calls to dev_err() from sisusb_probe() as
> reporting memory allocation failures is redundant:
>
>   - Remove a call to dev_err() that was reporting unsuccesful call to
>     kzalloc().
>
>   - Remove two calls to dev_err() that were reporting unsuccesful calls
>     to kmalloc().
>
>   - Remove a call to dev_err() that was reporting unsuccesful call to
>     kmalloc(), and replace it by code that clean up previously allocated
>     resources and abort the probe with -ENOMEM. Before this modification
>     sisusb->SiS_Pr could be dereferenced even it was null.

    I think the bug fix should be in its own patch. Don't intermix fixes with 
cleanups please.

> Signed-off-by: Peter Senna Tschudin <peter.senna@collabora.com>
> ---
> Tested by compilation only.
>
>   drivers/usb/misc/sisusbvga/sisusb.c | 10 ++++------
>   1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
> index 6cce4fb..875e365 100644
> --- a/drivers/usb/misc/sisusbvga/sisusb.c
> +++ b/drivers/usb/misc/sisusbvga/sisusb.c
[...]
>   	/* Allocate our SiS_Pr */
>   	sisusb->SiS_Pr = kmalloc(sizeof(struct SiS_Private), GFP_KERNEL);
>   	if (!sisusb->SiS_Pr) {
> -		dev_err(&sisusb->sisusb_dev->dev, "Failed to allocate SiS_Pr\n");
> +		retval = -ENOMEM;
> +		goto error_4;
>   	}
>   #endif
>

MBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [next] | [standalone]


#1303652 — Re: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path

FromPeter Senna Tschudin <peter.senna@collabora.com>
Date2016-01-07 16:20 +0100
SubjectRe: [PATCH 4/5] usb-misc: sisusbvga: Remove kmalloc logs and fix error path
Message-ID<qOkw2-1qX-7@gated-at.bofh.it>
In reply to#1302959
On Wed, Jan 06, 2016 at 09:28:41PM +0300, Sergei Shtylyov wrote:
> Hello.
> 
> On 1/5/2016 7:54 PM, Peter Senna Tschudin wrote:
> 
> >From: Peter Senna Tschudin <peter.senna@gmail.com>
> >
> >This patch remove four calls to dev_err() from sisusb_probe() as
> >reporting memory allocation failures is redundant:
> >
> >  - Remove a call to dev_err() that was reporting unsuccesful call to
> >    kzalloc().
> >
> >  - Remove two calls to dev_err() that were reporting unsuccesful calls
> >    to kmalloc().
> >
> >  - Remove a call to dev_err() that was reporting unsuccesful call to
> >    kmalloc(), and replace it by code that clean up previously allocated
> >    resources and abort the probe with -ENOMEM. Before this modification
> >    sisusb->SiS_Pr could be dereferenced even it was null.
> 
>    I think the bug fix should be in its own patch. Don't intermix fixes with
> cleanups please.

Ok, I'll resend the series with the following changes:
 - split patch 1: vertical and horizontal changes
 - split patch 4: cleanups and fix

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web