Commit 1c1acab0367d88ad5da2b9db2efdf2699113ec88
Committed by
James Bottomley
1 parent
fc91961ce5
Exists in
master
and in
4 other branches
[SCSI] drivers/message/fusion: Return -ENOMEM on memory allocation failure
In this code, 0 is returned on memory allocation failure, even though other failures return -ENOMEM or other similar values. A simplified version of the semantic match that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression ret; expression x,e1,e2,e3; @@ ret = 0 ... when != ret = e1 *x = \(kmalloc\|kcalloc\|kzalloc\)(...) ... when != ret = e2 if (x == NULL) { ... when != ret = e3 return ret; } // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: "Desai, Kashyap" <Kashyap.Desai@lsi.com> Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Showing 1 changed file with 3 additions and 1 deletions Side-by-side Diff
drivers/message/fusion/mptbase.c
... | ... | @@ -5945,8 +5945,10 @@ |
5945 | 5945 | goto out; |
5946 | 5946 | |
5947 | 5947 | mem = kmalloc(iocpage2sz, GFP_KERNEL); |
5948 | - if (!mem) | |
5948 | + if (!mem) { | |
5949 | + rc = -ENOMEM; | |
5949 | 5950 | goto out; |
5951 | + } | |
5950 | 5952 | |
5951 | 5953 | memcpy(mem, (u8 *)pIoc2, iocpage2sz); |
5952 | 5954 | ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem; |