From: Amit Ghadge <amitg.b14@gmail.com>
To: mdharm-usb@one-eyed-alien.net
Cc: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
Amit Ghadge <amitg.b14@gmail.com>
Subject: [PATCH] usb: storage: alauda: Clean up if function returned NULL on failure
Date: Tue, 13 Sep 2016 22:48:51 +0530 [thread overview]
Message-ID: <1473787131-11114-1-git-send-email-amitg.b14@gmail.com> (raw)
Some functions return NULL on failure, used !x instead of x==NULL.
Signed-off-by: Amit Ghadge <amitg.b14@gmail.com>
---
drivers/usb/storage/alauda.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 1d8b03c..8f25bc8 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -425,7 +425,7 @@ static int alauda_init_media(struct us_data *us)
usb_stor_dbg(us, "Media signature: %4ph\n", data);
media_info = alauda_card_find_id(data[1]);
- if (media_info == NULL) {
+ if (!media_info) {
pr_warn("alauda_init_media: Unrecognised media signature: %4ph\n",
data);
return USB_STOR_TRANSPORT_ERROR;
@@ -579,7 +579,7 @@ static int alauda_read_map(struct us_data *us, unsigned int zone)
unsigned int zone_base_pba = zone * zonesize;
u16 *lba_to_pba = kcalloc(zonesize, sizeof(u16), GFP_NOIO);
u16 *pba_to_lba = kcalloc(zonesize, sizeof(u16), GFP_NOIO);
- if (lba_to_pba == NULL || pba_to_lba == NULL) {
+ if (!lba_to_pba || !pba_to_lba) {
result = USB_STOR_TRANSPORT_ERROR;
goto error;
}
@@ -693,8 +693,8 @@ out:
*/
static void alauda_ensure_map_for_zone(struct us_data *us, unsigned int zone)
{
- if (MEDIA_INFO(us).lba_to_pba[zone] == NULL
- || MEDIA_INFO(us).pba_to_lba[zone] == NULL)
+ if (!MEDIA_INFO(us).lba_to_pba[zone]
+ || !MEDIA_INFO(us).pba_to_lba[zone])
alauda_read_map(us, zone);
}
@@ -939,7 +939,7 @@ static int alauda_read_data(struct us_data *us, unsigned long address,
len = min(sectors, blocksize) * (pagesize + 64);
buffer = kmalloc(len, GFP_NOIO);
- if (buffer == NULL) {
+ if (!buffer) {
printk(KERN_WARNING "alauda_read_data: Out of memory\n");
return USB_STOR_TRANSPORT_ERROR;
}
@@ -1033,7 +1033,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address,
len = min(sectors, blocksize) * pagesize;
buffer = kmalloc(len, GFP_NOIO);
- if (buffer == NULL) {
+ if (!buffer) {
printk(KERN_WARNING "alauda_write_data: Out of memory\n");
return USB_STOR_TRANSPORT_ERROR;
}
@@ -1043,7 +1043,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address,
* overwrite parts with the new data, and manipulate the redundancy data
*/
blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO);
- if (blockbuffer == NULL) {
+ if (!blockbuffer) {
printk(KERN_WARNING "alauda_write_data: Out of memory\n");
kfree(buffer);
return USB_STOR_TRANSPORT_ERROR;
--
2.5.5
next reply other threads:[~2016-09-13 17:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-13 17:18 Amit Ghadge [this message]
2016-09-27 10:44 ` Greg KH
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=1473787131-11114-1-git-send-email-amitg.b14@gmail.com \
--to=amitg.b14@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mdharm-usb@one-eyed-alien.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
all inboxes | Powered by JetHome®