linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] usb: storage: alauda: Clean up if function returned NULL on failure
@ 2016-09-13 17:18 Amit Ghadge
  2016-09-27 10:44 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Amit Ghadge @ 2016-09-13 17:18 UTC (permalink / raw)
  To: mdharm-usb; +Cc: gregkh, linux-kernel, Amit Ghadge

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

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

* Re: [PATCH] usb: storage: alauda: Clean up if function returned NULL on failure
  2016-09-13 17:18 [PATCH] usb: storage: alauda: Clean up if function returned NULL on failure Amit Ghadge
@ 2016-09-27 10:44 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2016-09-27 10:44 UTC (permalink / raw)
  To: Amit Ghadge; +Cc: mdharm-usb, linux-kernel

On Tue, Sep 13, 2016 at 10:48:51PM +0530, Amit Ghadge wrote:
> 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(-)

Same mailing list comment here...

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

end of thread, other threads:[~2016-09-27 10:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-13 17:18 [PATCH] usb: storage: alauda: Clean up if function returned NULL on failure Amit Ghadge
2016-09-27 10:44 ` Greg KH

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).