[PATCH 1/2] nvme: Fix nvme reset command timeout handling

Johannes Thumshirn jthumshirn at suse.de
Fri Jul 28 00:58:34 PDT 2017


On Thu, Jul 27, 2017 at 12:58:40PM -0400, Keith Busch wrote:
>  static void nvme_set_latency_tolerance(struct device *dev, s32 val)
> @@ -1856,17 +1857,25 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
>  
>  	kfree(id);
>  
> +	if (ret < 0)
> +		return ret;
> +

This is a bit confusing IMHO, how about this?

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 3b77cfe5aa1e..71a97db3ce91 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -1835,13 +1835,16 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 		 * In fabrics we need to verify the cntlid matches the
 		 * admin connect
 		 */
-		if (ctrl->cntlid != le16_to_cpu(id->cntlid))
+		if (ctrl->cntlid != le16_to_cpu(id->cntlid)) {
 			ret = -EINVAL;
+			goto free_id;
+		}
 
 		if (!ctrl->opts->discovery_nqn && !ctrl->kas) {
 			dev_err(ctrl->device,
 				"keep-alive support is mandatory for fabrics\n");
 			ret = -EINVAL;
+			goto free_id;
 		}
 	} else {
 		ctrl->cntlid = le16_to_cpu(id->cntlid);
@@ -1862,6 +1865,10 @@ int nvme_init_identify(struct nvme_ctrl *ctrl)
 	ctrl->identified = true;
 
 	return ret;
+
+free_id:
+	kfree(id);
+	return ret;
 }
 EXPORT_SYMBOL_GPL(nvme_init_identify);

Or ditch the goto and do a kfree(id); return ret; directly in the if blocks?

Byte,
	Johannes
 
-- 
Johannes Thumshirn                                          Storage
jthumshirn at suse.de                                +49 911 74053 689
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850



More information about the Linux-nvme mailing list