From: Peter Senna Tschudin <peter.senna@collabora.com>
To: thomas@winischhofer.net, gregkh@linuxfoundation.org,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
joe@perches.com, sergei.shtylyov@cogentembedded.com
Cc: Peter Senna Tschudin <peter.senna@collabora.com>
Subject: [PATCH V2 7/7] usb-misc: sisusbvga: fix error path
Date: Fri, 15 Jan 2016 18:41:34 +0100 [thread overview]
Message-ID: <1452879694-21206-8-git-send-email-peter.senna@collabora.com> (raw)
In-Reply-To: <1452879694-21206-1-git-send-email-peter.senna@collabora.com>
Remove a call to dev_err() that was reporting an unsuccesful call to
kmalloc(), as reporting memory allocation failures is redundant. Instead
of logging the error, clean up previously allocated resources and abort
the probe with -ENOMEM. Before this change sisusb->SiS_Pr could be
dereferenced even if null after failure of memory allocation.
Signed-off-by: Peter Senna Tschudin <peter.senna@collabora.com>
---
Changes from V1:
- This patch fixes the bug and does cleanup only on the error path that was
causing the bug.
Tested by compilation only.
drivers/usb/misc/sisusbvga/sisusb.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/misc/sisusbvga/sisusb.c b/drivers/usb/misc/sisusbvga/sisusb.c
index b3713d5..a22de52 100644
--- a/drivers/usb/misc/sisusbvga/sisusb.c
+++ b/drivers/usb/misc/sisusbvga/sisusb.c
@@ -3112,7 +3112,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
next prev parent reply other threads:[~2016-01-15 17:42 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-15 17:41 [PATCH V2 0/7] usb-misc: sisusbvga: cleanup and bug fix Peter Senna Tschudin
2016-01-15 17:41 ` [PATCH V2 1/7] usb-misc: sisusbvga: Fix coding style: horizontal whitespace changes Peter Senna Tschudin
2016-01-15 17:56 ` Joe Perches
2016-01-15 18:09 ` Peter Senna
2016-01-15 18:21 ` Alan Stern
2016-01-15 17:41 ` [PATCH V2 2/7] usb-misc: sisusbvga: Fix coding style: vertical " Peter Senna Tschudin
2016-01-15 17:41 ` [PATCH V2 3/7] usb-misc: sisusbvga: Fix coding style: braces, parenthesis, comment Peter Senna Tschudin
2016-01-15 17:41 ` [PATCH V2 4/7] usb-misc: sisusbvga: Fix coding style: remove assignment from if tests Peter Senna Tschudin
2016-01-15 17:41 ` [PATCH V2 5/7] usb-misc: sisusbvga: Remove null test before calls to kfree() Peter Senna Tschudin
2016-01-15 17:41 ` [PATCH V2 6/7] usb-misc: sisusbvga: Remove memory allocation logs Peter Senna Tschudin
2016-01-15 17:41 ` Peter Senna Tschudin [this message]
2016-01-15 17:51 ` [PATCH V2 0/7] usb-misc: sisusbvga: cleanup and bug fix Joe Perches
2016-01-15 18:07 ` Jason Cooper
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=1452879694-21206-8-git-send-email-peter.senna@collabora.com \
--to=peter.senna@collabora.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=sergei.shtylyov@cogentembedded.com \
--cc=thomas@winischhofer.net \
/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;
as well as URLs for NNTP newsgroup(s).