Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1550758

Re: [PATCH 7/7] misc: intel-ish-client: add intel ishtp clients driver

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Greg KH <gregkh@linuxfoundation.org>
Newsgroups linux.kernel
Subject Re: [PATCH 7/7] misc: intel-ish-client: add intel ishtp clients driver
Date Wed, 04 Jan 2017 14:10:02 +0100
Message-ID <sVTui-55P-55@gated-at.bofh.it> (permalink)
References <sRmQh-dg-7@gated-at.bofh.it> <sRmQh-dg-15@gated-at.bofh.it>
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
User-Agent Mutt/1.7.2 (2016-11-26)
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 79
Organization linux.* mail to news gateway
X-Original-Cc jikos@kernel.org, benjamin.tissoires@redhat.com, srinivas.pandruvada@linux.intel.com, arnd@arndb.de, andriy.shevchenko@intel.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org
X-Original-Date Wed, 4 Jan 2017 14:09:03 +0100
X-Original-Message-ID <20170104130903.GA8832@kroah.com>
X-Original-References <1482456149-4841-1-git-send-email-even.xu@intel.com> <1482456149-4841-7-git-send-email-even.xu@intel.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1550758

Show key headers only | View raw


On Fri, Dec 23, 2016 at 09:22:29AM +0800, Even Xu wrote:
> +/**
> + * ishtp_cl_probe() - ISHTP client driver probe
> + * @cl_device:		ISHTP client device instance
> + *
> + * This function gets called on device create on ISHTP bus
> + *
> + * Return: 0 on success, non zero on error
> + */
> +static int ishtp_cl_probe(struct ishtp_cl_device *cl_device)
> +{
> +	struct ishtp_cl_miscdev *ishtp_cl_misc;
> +	int ret;
> +
> +	if (!cl_device)
> +		return -ENODEV;
> +
> +	ishtp_cl_misc = kzalloc(sizeof(struct ishtp_cl_miscdev),
> +				GFP_KERNEL);
> +	if (!ishtp_cl_misc)
> +		return -ENOMEM;
> +
> +	if (uuid_le_cmp(ishtp_smhi_guid,
> +			cl_device->fw_client->props.protocol_name) == 0) {
> +		ishtp_cl_misc->cl_miscdev.name = "ish-smhi";
> +	} else if (uuid_le_cmp(ishtp_trace_guid,
> +			cl_device->fw_client->props.protocol_name) == 0) {
> +		ishtp_cl_misc->cl_miscdev.name = "ish-trace";
> +	} else if (uuid_le_cmp(ishtp_traceconfig_guid,
> +			cl_device->fw_client->props.protocol_name) == 0) {
> +		ishtp_cl_misc->cl_miscdev.name = "ish-tracec";
> +	} else if (uuid_le_cmp(ishtp_loader_guid,
> +			cl_device->fw_client->props.protocol_name) == 0) {
> +		ishtp_cl_misc->cl_miscdev.name = "ish-loader";
> +	} else {
> +		dev_err(&cl_device->dev, "Not supported client\n");
> +		ret = -ENODEV;
> +		goto release_mem;
> +	}
> +
> +	ishtp_cl_misc->cl_miscdev.parent = &cl_device->dev;
> +	ishtp_cl_misc->cl_miscdev.fops = &ishtp_cl_fops;
> +	ishtp_cl_misc->cl_miscdev.minor = MISC_DYNAMIC_MINOR,
> +
> +	ret = misc_register(&ishtp_cl_misc->cl_miscdev);
> +	if (ret) {
> +		dev_err(&cl_device->dev, "misc device register failed\n");
> +		goto release_mem;
> +	}

Now your userspace device node is created and can be opened up and
accessed.  But:

> +
> +	ishtp_cl_misc->cl_device = cl_device;
> +
> +	init_waitqueue_head(&ishtp_cl_misc->read_wait);
> +
> +	ishtp_set_drvdata(cl_device, ishtp_cl_misc);
> +
> +	ishtp_get_device(cl_device);
> +
> +	mutex_init(&ishtp_cl_misc->cl_mutex);
> +
> +	INIT_WORK(&ishtp_cl_misc->reset_work, ishtp_cl_reset_handler);
> +
> +	/* Register event callback */
> +	ishtp_register_event_cb(cl_device, ishtp_cl_event_cb);

You were not done setting up the device.  What nasty races just
happened?

And the above functions can never fail?  Why are you grabbing a refernce
to the cl_device yet doing nothing with it?  That feels really broken
and wrong.

thanks,

greg k-h

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH 7/7] misc: intel-ish-client: add intel ishtp clients  driver Greg KH <gregkh@linuxfoundation.org> - 2017-01-04 14:10 +0100

csiph-web