From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Sherry Sun <sherry.sun@nxp.com>,
gregkh@linuxfoundation.org, jirislaby@kernel.org,
robh@kernel.org
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-imx@nxp.com
Subject: Re: [PATCH] tty: serdev: serdev-ttyport: add devt for ctrl->dev
Date: Mon, 20 Mar 2023 08:55:51 +0300 [thread overview]
Message-ID: <d2c39186-9641-4aaa-90cb-bce92b2331f6@kili.mountain> (raw)
In-Reply-To: <20230315105400.23426-1-sherry.sun@nxp.com>
Hi Sherry,
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Sherry-Sun/tty-serdev-serdev-ttyport-add-devt-for-ctrl-dev/20230315-185913
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
patch link: https://lore.kernel.org/r/20230315105400.23426-1-sherry.sun%40nxp.com
patch subject: [PATCH] tty: serdev: serdev-ttyport: add devt for ctrl->dev
config: x86_64-randconfig-m001 (https://download.01.org/0day-ci/archive/20230316/202303160201.bnmM2caW-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-8) 11.3.0
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Link: https://lore.kernel.org/r/202303160201.bnmM2caW-lkp@intel.com/
smatch warnings:
drivers/tty/serdev/serdev-ttyport.c:273 serdev_tty_port_register() warn: variable dereferenced before check 'drv' (see line 270)
vim +/drv +273 drivers/tty/serdev/serdev-ttyport.c
bed35c6dfa6a36 Rob Herring 2017-02-02 264 struct device *serdev_tty_port_register(struct tty_port *port,
bed35c6dfa6a36 Rob Herring 2017-02-02 265 struct device *parent,
bed35c6dfa6a36 Rob Herring 2017-02-02 266 struct tty_driver *drv, int idx)
bed35c6dfa6a36 Rob Herring 2017-02-02 267 {
bed35c6dfa6a36 Rob Herring 2017-02-02 268 struct serdev_controller *ctrl;
bed35c6dfa6a36 Rob Herring 2017-02-02 269 struct serport *serport;
225acc66b125b9 Sherry Sun 2023-03-15 @270 dev_t devt = MKDEV(drv->major, drv->minor_start) + idx;
^^^^^ ^^^^^
Dereferences.
bed35c6dfa6a36 Rob Herring 2017-02-02 271 int ret;
bed35c6dfa6a36 Rob Herring 2017-02-02 272
bed35c6dfa6a36 Rob Herring 2017-02-02 @273 if (!port || !drv || !parent)
^^^^
Checked too late. Are these checks really required?
bed35c6dfa6a36 Rob Herring 2017-02-02 274 return ERR_PTR(-ENODEV);
bed35c6dfa6a36 Rob Herring 2017-02-02 275
bed35c6dfa6a36 Rob Herring 2017-02-02 276 ctrl = serdev_controller_alloc(parent, sizeof(struct serport));
bed35c6dfa6a36 Rob Herring 2017-02-02 277 if (!ctrl)
bed35c6dfa6a36 Rob Herring 2017-02-02 278 return ERR_PTR(-ENOMEM);
bed35c6dfa6a36 Rob Herring 2017-02-02 279 serport = serdev_controller_get_drvdata(ctrl);
bed35c6dfa6a36 Rob Herring 2017-02-02 280
bed35c6dfa6a36 Rob Herring 2017-02-02 281 serport->port = port;
bed35c6dfa6a36 Rob Herring 2017-02-02 282 serport->tty_idx = idx;
bed35c6dfa6a36 Rob Herring 2017-02-02 283 serport->tty_drv = drv;
bed35c6dfa6a36 Rob Herring 2017-02-02 284
225acc66b125b9 Sherry Sun 2023-03-15 285 ctrl->dev.devt = devt;
bed35c6dfa6a36 Rob Herring 2017-02-02 286 ctrl->ops = &ctrl_ops;
bed35c6dfa6a36 Rob Herring 2017-02-02 287
aee5da7838787f Johan Hovold 2017-04-11 288 port->client_ops = &client_ops;
aee5da7838787f Johan Hovold 2017-04-11 289 port->client_data = ctrl;
aee5da7838787f Johan Hovold 2017-04-11 290
bed35c6dfa6a36 Rob Herring 2017-02-02 291 ret = serdev_controller_add(ctrl);
bed35c6dfa6a36 Rob Herring 2017-02-02 292 if (ret)
aee5da7838787f Johan Hovold 2017-04-11 293 goto err_reset_data;
bed35c6dfa6a36 Rob Herring 2017-02-02 294
bed35c6dfa6a36 Rob Herring 2017-02-02 295 dev_info(&ctrl->dev, "tty port %s%d registered\n", drv->name, idx);
bed35c6dfa6a36 Rob Herring 2017-02-02 296 return &ctrl->dev;
bed35c6dfa6a36 Rob Herring 2017-02-02 297
aee5da7838787f Johan Hovold 2017-04-11 298 err_reset_data:
aee5da7838787f Johan Hovold 2017-04-11 299 port->client_data = NULL;
0c5aae59270fb1 Johan Hovold 2020-02-10 300 port->client_ops = &tty_port_default_client_ops;
bed35c6dfa6a36 Rob Herring 2017-02-02 301 serdev_controller_put(ctrl);
aee5da7838787f Johan Hovold 2017-04-11 302
bed35c6dfa6a36 Rob Herring 2017-02-02 303 return ERR_PTR(ret);
bed35c6dfa6a36 Rob Herring 2017-02-02 304 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests
prev parent reply other threads:[~2023-03-20 5:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-15 10:54 [PATCH] tty: serdev: serdev-ttyport: add devt for ctrl->dev Sherry Sun
2023-03-15 11:10 ` Greg KH
2023-03-15 13:37 ` Sherry Sun
2023-03-20 5:55 ` Dan Carpenter [this message]
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=d2c39186-9641-4aaa-90cb-bce92b2331f6@kili.mountain \
--to=error27@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-imx@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=robh@kernel.org \
--cc=sherry.sun@nxp.com \
/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
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).