Message ID | 20211029050956.59817-1-james.hilliard1@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | [1/1] diskpart: fix context memory leak in hybrid mode | expand |
On 29.10.21 07:09, James Hilliard wrote: > It appears that fdisk_unref_context doesn't automatically free > the parent context, so we need to do so explicitely. > > Signed-off-by: James Hilliard <james.hilliard1@gmail.com> > --- > handlers/diskpart_handler.c | 9 ++++++++- > 1 file changed, 8 insertions(+), 1 deletion(-) > > diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c > index f9327b5..e08c10e 100644 > --- a/handlers/diskpart_handler.c > +++ b/handlers/diskpart_handler.c > @@ -739,6 +739,13 @@ static int diskpart_write_table(struct fdisk_context *cxt, struct create_table * > return ret; > } > > +static void diskpart_unref_context(struct fdisk_context *cxt) > +{ > + if (IS_HYBRID(cxt)) > + fdisk_unref_context(PARENT(cxt)); > + fdisk_unref_context(cxt); > +} > + > static int diskpart(struct img_type *img, > void __attribute__ ((__unused__)) *data) > { > @@ -945,7 +952,7 @@ handler_exit: > WARN("Error deassign device %s", img->device); > > handler_release: > - fdisk_unref_context(cxt); > + diskpart_unref_context(cxt); > > /* > * Kernel rereads the partition table and add just a delay to be sure > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/handlers/diskpart_handler.c b/handlers/diskpart_handler.c index f9327b5..e08c10e 100644 --- a/handlers/diskpart_handler.c +++ b/handlers/diskpart_handler.c @@ -739,6 +739,13 @@ static int diskpart_write_table(struct fdisk_context *cxt, struct create_table * return ret; } +static void diskpart_unref_context(struct fdisk_context *cxt) +{ + if (IS_HYBRID(cxt)) + fdisk_unref_context(PARENT(cxt)); + fdisk_unref_context(cxt); +} + static int diskpart(struct img_type *img, void __attribute__ ((__unused__)) *data) { @@ -945,7 +952,7 @@ handler_exit: WARN("Error deassign device %s", img->device); handler_release: - fdisk_unref_context(cxt); + diskpart_unref_context(cxt); /* * Kernel rereads the partition table and add just a delay to be sure
It appears that fdisk_unref_context doesn't automatically free the parent context, so we need to do so explicitely. Signed-off-by: James Hilliard <james.hilliard1@gmail.com> --- handlers/diskpart_handler.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)