Patchwork mtd/sst25l: check for null consistently

login
register
mail settings
Submitter Dan Carpenter
Date May 22, 2010, 8:16 p.m.
Message ID <20100522201626.GJ22515@bicker>
Download mbox | patch
Permalink /patch/53283/
State Accepted
Commit a4b81ca50974051195b11ca173da073b961f94d5
Headers show

Comments

Dan Carpenter - May 22, 2010, 8:16 p.m.
The rest of the function assumes that "data" can be null.  I don't know
the code well enough to say whether it can actually be null, but there 
is no harm in checking here.

Signed-off-by: Dan Carpenter <error27@gmail.com>
Artem Bityutskiy - June 12, 2010, 2:21 p.m.
On Sat, 2010-05-22 at 22:16 +0200, Dan Carpenter wrote:
> The rest of the function assumes that "data" can be null.  I don't know
> the code well enough to say whether it can actually be null, but there 
> is no harm in checking here.
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Pushed to l2-mtd-2.6.git, Thanks.

Patch

diff --git a/drivers/mtd/devices/sst25l.c b/drivers/mtd/devices/sst25l.c
index ab5d8cd..684247a 100644
--- a/drivers/mtd/devices/sst25l.c
+++ b/drivers/mtd/devices/sst25l.c
@@ -454,7 +454,7 @@  static int __init sst25l_probe(struct spi_device *spi)
 						  parts, nr_parts);
 		}
 
-	} else if (data->nr_parts) {
+	} else if (data && data->nr_parts) {
 		dev_warn(&spi->dev, "ignoring %d default partitions on %s\n",
 			 data->nr_parts, data->name);
 	}