Skip to content

Commit 2f5af4a

Browse files
geertuaxboe
authored andcommitted
lightnvm: fix uninitialized pointer in nvm_remove_tgt()
With gcc 4.1: drivers/lightnvm/core.c: In function ‘nvm_remove_tgt’: drivers/lightnvm/core.c:510: warning: ‘t’ is used uninitialized in this function Indeed, if no NVM devices have been registered, t will be an uninitialized pointer, and may be dereferenced later. A call to nvm_remove_tgt() can be triggered from userspace by issuing the NVM_DEV_REMOVE ioctl on the lightnvm control device. Fix this by preinitializing t to NULL. Fixes: 843f2ed ("lightnvm: do not remove instance under global lock") Signed-off-by: Geert Uytterhoeven <[email protected]> Signed-off-by: Matias Bjørling <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 510fd8e commit 2f5af4a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/lightnvm/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ static void __nvm_remove_target(struct nvm_target *t, bool graceful)
478478
*/
479479
static int nvm_remove_tgt(struct nvm_ioctl_remove *remove)
480480
{
481-
struct nvm_target *t;
481+
struct nvm_target *t = NULL;
482482
struct nvm_dev *dev;
483483

484484
down_read(&nvm_lock);

0 commit comments

Comments
 (0)