LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Dragan Cvetic <draganc@xilinx.com>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: "arnd@arndb.de" <arnd@arndb.de>,
	Michal Simek <michals@xilinx.com>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"robh+dt@kernel.org" <robh+dt@kernel.org>,
	"mark.rutland@arm.com" <mark.rutland@arm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Derek Kiernan <dkiernan@xilinx.com>
Subject: RE: [PATCH V4 04/12] misc: xilinx_sdfec: Add open, close and ioctl
Date: Thu, 6 Jun 2019 18:22:07 +0000	[thread overview]
Message-ID: <CH2PR02MB63591C650DB8C7E15D9D3CCDCB170@CH2PR02MB6359.namprd02.prod.outlook.com> (raw)
In-Reply-To: <20190606132842.GC7943@kroah.com>



> -----Original Message-----
> From: Greg KH [mailto:gregkh@linuxfoundation.org]
> Sent: Thursday 6 June 2019 14:29
> To: Dragan Cvetic <draganc@xilinx.com>
> Cc: arnd@arndb.de; Michal Simek <michals@xilinx.com>; linux-arm-kernel@lists.infradead.org; robh+dt@kernel.org;
> mark.rutland@arm.com; devicetree@vger.kernel.org; linux-kernel@vger.kernel.org; Derek Kiernan <dkiernan@xilinx.com>
> Subject: Re: [PATCH V4 04/12] misc: xilinx_sdfec: Add open, close and ioctl
> 
> On Sat, May 25, 2019 at 12:37:17PM +0100, Dragan Cvetic wrote:
> > +static int xsdfec_dev_open(struct inode *iptr, struct file *fptr)
> > +{
> > +	return 0;
> > +}
> > +
> > +static int xsdfec_dev_release(struct inode *iptr, struct file *fptr)
> > +{
> > +	return 0;
> > +}
> 
> empty open/close functions are never needed, just drop them.

Accepted.
Will remove them.

> 
> > +
> > +static long xsdfec_dev_ioctl(struct file *fptr, unsigned int cmd,
> > +			     unsigned long data)
> > +{
> > +	struct xsdfec_dev *xsdfec;
> > +	void __user *arg = NULL;
> > +	int rval = -EINVAL;
> > +
> > +	xsdfec = container_of(fptr->private_data, struct xsdfec_dev, miscdev);
> > +	if (!xsdfec)
> > +		return rval;
> 
> It is impossible for container_of() to return NULL, unless something
> very magical and rare just happened.  It's just doing pointer math, you
> can never check the return value of it.

Accepted.
Will remove if statement.

> 
> > +
> > +	if (_IOC_TYPE(cmd) != XSDFEC_MAGIC)
> > +		return -ENOTTY;
> 
> How can this happen?

Accepted.
Will be removed.

> 
> > +
> > +	/* check if ioctl argument is present and valid */
> > +	if (_IOC_DIR(cmd) != _IOC_NONE) {
> > +		arg = (void __user *)data;
> > +		if (!arg)
> > +			return rval;
> > +	}
> > +
> > +	switch (cmd) {
> > +	default:
> > +		/* Should not get here */
> > +		dev_warn(xsdfec->dev, "Undefined SDFEC IOCTL");
> 
> Nice that userspace has a way to fill up the kernel log :(
> 
> Just return the correct error here, don't log it.

Accepted.
Will remove log.

> 
> thanks,
> 
> greg k-h

  reply	other threads:[~2019-06-06 18:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-25 11:37 [PATCH V4 00/12] misc: xilinx sd-fec drive Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 01/12] dt-bindings: xilinx-sdfec: Add SDFEC binding Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 02/12] misc: xilinx-sdfec: add core driver Dragan Cvetic
2019-06-06 13:25   ` Greg KH
2019-06-06 18:16     ` Dragan Cvetic
2019-06-06 19:04       ` Greg KH
2019-05-25 11:37 ` [PATCH V4 03/12] misc: xilinx_sdfec: Add CCF support Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 04/12] misc: xilinx_sdfec: Add open, close and ioctl Dragan Cvetic
2019-06-06 13:26   ` Greg KH
2019-06-06 18:18     ` Dragan Cvetic
2019-06-06 13:28   ` Greg KH
2019-06-06 18:22     ` Dragan Cvetic [this message]
2019-06-07 10:58     ` Dragan Cvetic
2019-06-07 15:57       ` Greg KH
2019-06-08 19:40         ` Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 05/12] misc: xilinx_sdfec: Store driver config and state Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 06/12] misc: xilinx_sdfec: Add ability to configure turbo Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 07/12] misc: xilinx_sdfec: Add ability to configure LDPC Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 08/12] misc: xilinx_sdfec: Add ability to get/set config Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 09/12] misc: xilinx_sdfec: Support poll file operation Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 10/12] misc: xilinx_sdfec: Add stats & status ioctls Dragan Cvetic
2019-06-06 14:11   ` Greg KH
2019-06-06 18:27     ` Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 11/12] Docs: misc: xilinx_sdfec: Add documentation Dragan Cvetic
2019-05-25 11:37 ` [PATCH V4 12/12] MAINTAINERS: add maintainer for SD-FEC Dragan Cvetic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CH2PR02MB63591C650DB8C7E15D9D3CCDCB170@CH2PR02MB6359.namprd02.prod.outlook.com \
    --to=draganc@xilinx.com \
    --cc=arnd@arndb.de \
    --cc=devicetree@vger.kernel.org \
    --cc=dkiernan@xilinx.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=michals@xilinx.com \
    --cc=robh+dt@kernel.org \
    --subject='RE: [PATCH V4 04/12] misc: xilinx_sdfec: Add open, close and ioctl' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).