[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220331054156.GI3293@kadam>
Date: Thu, 31 Mar 2022 08:41:56 +0300
From: Dan Carpenter <dan.carpenter@...cle.com>
To: Wenchao Hao <haowenchao@...wei.com>
Cc: fmdefrancesco@...il.com, axboe@...nel.dk, jejb@...ux.ibm.com,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-scsi@...r.kernel.org, martin.petersen@...cle.com,
syzbot+f08c77040fa163a75a46@...kaller.appspotmail.com,
syzkaller-bugs@...glegroups.com, linfeilong@...wei.com
Subject: Re: [PATCH] scsi: sd: call device_del() if device_add_disk() fails
On Thu, Mar 31, 2022 at 11:26:22AM -0400, 'Wenchao Hao' via syzkaller-bugs wrote:
> I do not think it's necessary to call device_del() on this path. If the device
> has been added, put_device() would delete it from sysfs. So the origin error
> handle is ok with me.
>
No. The original is buggy and it was detected at runtime by syzbot.
It's not static analysis, it is an actual bug found in testing.
The device_put() unwinds device_initialize(). The device_del() unwinds
device_add(). Take a look at the comments to device_add() or take a
look at how device_register/unregister() work.
The temptation was to call device_unregister() which is a combined
device_del(); device_put(); but when the device_initialize() and
device_add() are called separately, then I think it is more readable to
call del and put separately as well.
regards,
dan carpenter
Powered by blists - more mailing lists