mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-09-21 03:43:03 +00:00
loop: remember whether sysfs_create_group() was done
commit d3349b6b3c373ac1fbfb040b810fcee5e2adc7e0 upstream. syzbot is hitting WARN() triggered by memory allocation fault injection [1] because loop module is calling sysfs_remove_group() when sysfs_create_group() failed. Fix this by remembering whether sysfs_create_group() succeeded. [1] https://syzkaller.appspot.com/bug?id=3f86c0edf75c86d2633aeb9dd69eccc70bc7e90b Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Reported-by: syzbot <syzbot+9f03168400f56df89dbc6f1751f4458fe739ff29@syzkaller.appspotmail.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Renamed sysfs_ready -> sysfs_inited. Change-Id: I8e58254e3741930ab034a647780595ede8e7a371 Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
ac182452bb
commit
679b06f980
|
@ -802,16 +802,17 @@ static struct attribute_group loop_attribute_group = {
|
||||||
.attrs= loop_attrs,
|
.attrs= loop_attrs,
|
||||||
};
|
};
|
||||||
|
|
||||||
static int loop_sysfs_init(struct loop_device *lo)
|
static void loop_sysfs_init(struct loop_device *lo)
|
||||||
{
|
{
|
||||||
return sysfs_create_group(&disk_to_dev(lo->lo_disk)->kobj,
|
lo->sysfs_inited = !sysfs_create_group(&disk_to_dev(lo->lo_disk)->kobj,
|
||||||
&loop_attribute_group);
|
&loop_attribute_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loop_sysfs_exit(struct loop_device *lo)
|
static void loop_sysfs_exit(struct loop_device *lo)
|
||||||
{
|
{
|
||||||
sysfs_remove_group(&disk_to_dev(lo->lo_disk)->kobj,
|
if (lo->sysfs_inited)
|
||||||
&loop_attribute_group);
|
sysfs_remove_group(&disk_to_dev(lo->lo_disk)->kobj,
|
||||||
|
&loop_attribute_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loop_config_discard(struct loop_device *lo)
|
static void loop_config_discard(struct loop_device *lo)
|
||||||
|
|
|
@ -60,6 +60,7 @@ struct loop_device {
|
||||||
wait_queue_head_t lo_event;
|
wait_queue_head_t lo_event;
|
||||||
/* wait queue for incoming requests */
|
/* wait queue for incoming requests */
|
||||||
wait_queue_head_t lo_req_wait;
|
wait_queue_head_t lo_req_wait;
|
||||||
|
bool sysfs_inited;
|
||||||
|
|
||||||
struct request_queue *lo_queue;
|
struct request_queue *lo_queue;
|
||||||
struct gendisk *lo_disk;
|
struct gendisk *lo_disk;
|
||||||
|
|
Loading…
Reference in a new issue