From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: oe-kbuild@lists.linux.dev, Takashi Iwai <tiwai@suse.de>,
lkp@intel.com, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org,
Thomas Zimmermann <tzimmermann@suse.de>
Subject: Re: drivers/gpu/drm/udl/udl_main.c:259 udl_get_urb_locked() warn: can 'unode' even be NULL?
Date: Tue, 02 May 2023 13:28:52 +0200 [thread overview]
Message-ID: <874jovotu3.wl-tiwai@suse.de> (raw)
In-Reply-To: <e35cd818-d2f7-4d5e-abf8-b3448ca224aa@kili.mountain>
On Tue, 02 May 2023 13:19:04 +0200,
Dan Carpenter wrote:
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: 2caeeb9d4a1bccd923b7918427f9e9ef7151ddd8
> commit: c5c354a3a4728045e1342166394c615d75d45377 drm/udl: Fix inconsistent urbs.count value during udl_free_urb_list()
> config: parisc-randconfig-m031-20230421 (https://download.01.org/0day-ci/archive/20230423/202304230801.ncoG1XDr-lkp@intel.com/config)
> compiler: hppa-linux-gcc (GCC) 12.1.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/202304230801.ncoG1XDr-lkp@intel.com/
>
> smatch warnings:
> drivers/gpu/drm/udl/udl_main.c:259 udl_get_urb_locked() warn: can 'unode' even be NULL?
>
> vim +/unode +259 drivers/gpu/drm/udl/udl_main.c
>
> c5c354a3a47280 Takashi Iwai 2022-09-08 236 static struct urb *udl_get_urb_locked(struct udl_device *udl, long timeout)
> 5320918b9a8786 Dave Airlie 2010-12-15 237 {
> c5c354a3a47280 Takashi Iwai 2022-09-08 238 struct urb_node *unode;
> 5320918b9a8786 Dave Airlie 2010-12-15 239
> c5c354a3a47280 Takashi Iwai 2022-09-08 240 assert_spin_locked(&udl->urbs.lock);
> 5320918b9a8786 Dave Airlie 2010-12-15 241
> acd45c56790a3b Takashi Iwai 2022-08-04 242 /* Wait for an in-flight buffer to complete and get re-queued */
> acd45c56790a3b Takashi Iwai 2022-08-04 243 if (!wait_event_lock_irq_timeout(udl->urbs.sleep,
> c5c354a3a47280 Takashi Iwai 2022-09-08 244 !udl->urbs.count ||
> acd45c56790a3b Takashi Iwai 2022-08-04 245 !list_empty(&udl->urbs.list),
> acd45c56790a3b Takashi Iwai 2022-08-04 246 udl->urbs.lock, timeout)) {
> acd45c56790a3b Takashi Iwai 2022-08-04 247 DRM_INFO("wait for urb interrupted: available: %d\n",
> acd45c56790a3b Takashi Iwai 2022-08-04 248 udl->urbs.available);
> c5c354a3a47280 Takashi Iwai 2022-09-08 249 return NULL;
> acd45c56790a3b Takashi Iwai 2022-08-04 250 }
> 5320918b9a8786 Dave Airlie 2010-12-15 251
> c5c354a3a47280 Takashi Iwai 2022-09-08 252 if (!udl->urbs.count)
> c5c354a3a47280 Takashi Iwai 2022-09-08 253 return NULL;
> c5c354a3a47280 Takashi Iwai 2022-09-08 254
> acd45c56790a3b Takashi Iwai 2022-08-04 255 unode = list_first_entry(&udl->urbs.list, struct urb_node, entry);
>
> Use list_first_entry_or_null() if this list can be empty.
>
> ed9605a66b62f2 Takashi Iwai 2022-09-08 256 list_del_init(&unode->entry);
> ^^^^^^^^^^^^
> dereference.
>
> 5320918b9a8786 Dave Airlie 2010-12-15 257 udl->urbs.available--;
> 5320918b9a8786 Dave Airlie 2010-12-15 258
> acd45c56790a3b Takashi Iwai 2022-08-04 @259 return unode ? unode->urb : NULL;
>
> Returns from list_first_entry() should never be checked for NULL.
>
> 5320918b9a8786 Dave Airlie 2010-12-15 260 }
This is rather a leftover at commit c5c354a3a472 ("drm/udl: Fix
inconsistent urbs.count value during udl_free_urb_list()").
The NULL check of unode at return became superfluous by the code
change there, hence it should be simply like
return ucode->urb;
OTOH, the current code doesn't cause any practical problem.
thanks,
Takashi
next prev parent reply other threads:[~2023-05-02 11:29 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-02 11:19 drivers/gpu/drm/udl/udl_main.c:259 udl_get_urb_locked() warn: can 'unode' even be NULL? Dan Carpenter
2023-05-02 11:28 ` Takashi Iwai [this message]
2023-05-02 11:38 ` Thomas Zimmermann
2023-05-02 13:02 ` Dan Carpenter
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=874jovotu3.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=dan.carpenter@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=tzimmermann@suse.de \
/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