Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

nvme: Add error check for xa_store in nvme_get_effects_log

The xa_store() may fail due to memory allocation failure because there
is no guarantee that the index csi is already used. This fix adds an
error check of the return value of xa_store() in nvme_get_effects_log().

Fixes: 1cf7a12e09aa ("nvme: use an xarray to lookup the Commands Supported and Effects log")
Signed-off-by: Keisuke Nishimura <keisuke.nishimura@inria.fr>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Keith Busch <kbusch@kernel.org>

authored by

Keisuke Nishimura and committed by
Keith Busch
ac32057a 32193789

+6 -2
+6 -2
drivers/nvme/host/core.c
··· 3092 3092 static int nvme_get_effects_log(struct nvme_ctrl *ctrl, u8 csi, 3093 3093 struct nvme_effects_log **log) 3094 3094 { 3095 - struct nvme_effects_log *cel = xa_load(&ctrl->cels, csi); 3095 + struct nvme_effects_log *old, *cel = xa_load(&ctrl->cels, csi); 3096 3096 int ret; 3097 3097 3098 3098 if (cel) ··· 3109 3109 return ret; 3110 3110 } 3111 3111 3112 - xa_store(&ctrl->cels, csi, cel, GFP_KERNEL); 3112 + old = xa_store(&ctrl->cels, csi, cel, GFP_KERNEL); 3113 + if (xa_is_err(old)) { 3114 + kfree(cel); 3115 + return xa_err(old); 3116 + } 3113 3117 out: 3114 3118 *log = cel; 3115 3119 return 0;