linux-next: manual merge of the scsi-mkp tree with the scsi tree
Subsystems (3)
Mark Brown
maintainerHi all,
Today's linux-next merge of the scsi-mkp tree got a conflict in:
drivers/scsi/mpi3mr/mpi3mr_transport.c
between commit:
29e3f0856e854 ("scsi: mpi3mr: Fix SAS port allocation and registration error handling")
from the scsi tree and commit:
0b5b2fb484f3b ("Merge tag 'v7.3-rc2' into 7.4/scsi-staging")
from the scsi-mkp tree.
I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.
drivers/scsi/mpi3mr/mpi3mr_transport.c +0 -0
@@@ -1567,10 -1567,12 +1567,10 @@@ static struct mpi3mr_sas_port *mpi3mr_s }list_for_each_entry_safe (mr_sas_phy, next, &mr_sas_port->phy_list, - port_siblings) { + port_siblings) { mr_sas_phy->phy_belongs_to_port =0 ;list_del (&mr_sas_phy->port_siblings); } - if (tgtdev) -mpi3mr_tgtdev_put (tgtdev);kfree (mr_sas_port);return NULL ; }
Hi Mark,
Quoted 29 lines · Mark Brown
Today's linux-next merge of the scsi-mkp tree got a conflict in:
drivers/scsi/mpi3mr/mpi3mr_transport.cbetween commit:
29e3f0856e854("scsi: mpi3mr: Fix SAS port allocation and registration error handling")from the scsi tree and commit:
0b5b2fb484f3b("Merge tag 'v7.3-rc2' into 7.4/scsi-staging")from the scsi-mkp tree.
I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.
drivers/scsi/mpi3mr/mpi3mr_transport.c +0
-0@@@ -1567,10 -1567,12 +1567,10 @@@ static struct mpi3mr_sas_port *mpi3mr_s } list_for_each_entry_safe(mr_sas_phy, next, &mr_sas_port->phy_list,
drivers/scsi/mpi3mr/mpi3mr_transport.c
Quoted 10 lines
drivers/scsi/mpi3mr/mpi3mr_transport.c +1
-1- port_siblings) { + port_siblings) { mr_sas_phy->phy_belongs_to_port =0 ;list_del (&mr_sas_phy->port_siblings); } - if (tgtdev) -mpi3mr_tgtdev_put (tgtdev);kfree (mr_sas_port);return NULL ; }
Are you sure this is correct?
Martin's conflict resolution in 0b5b2fb484f3b kept the
if (tgtdev)
mpi3mr_tgtdev_put(tgtdev);part.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Mark Brown
maintainerQuoted 9 lines · Geert Uytterhoeven
Quoted 6 lines · Mark Brown
} - if (tgtdev) - mpi3mr_tgtdev_put(tgtdev); kfree(mr_sas_port); return NULL;}
Quoted 7 lines
Are you sure this is correct?
Martin's conflict resolution in0b5b2fb484f3bkept theif (tgtdev) mpi3mr_tgtdev_put(tgtdev);part.
Dunno. There was another put came in further up the function.
Hi Mark,
Quoted 13 lines · Mark Brown
Quoted 11 lines · Geert Uytterhoeven
Quoted 6 lines · Mark Brown
} - if (tgtdev) - mpi3mr_tgtdev_put(tgtdev); kfree(mr_sas_port); return NULL;}
Are you sure this is correct?
Martin's conflict resolution in0b5b2fb484f3bkept the
Quoted 6 lines
Quoted 4 lines
if (tgtdev) mpi3mr_tgtdev_put(tgtdev);part.
Dunno. There was another put came in further up the function.
Right. So Martin's resolution looks incorrect, too, as it calls mpi3mr_tgtdev_put(tgtdev) twice.
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Hi Geert and Mark,
Author of commit 29e3f0856e854 here - confirming Geert is right, this is a genuine double-put, not a style difference.
mpi3mr_tgtdev_put() is a plain kref_put(&s->ref_count, mpi3mr_free_tgtdev). The block earlier in the same function already does the full cleanup on this error path:
if (tgtdev) {
tgtdev->dev_spec.sas_sata_inf.pend_sas_rphy_add = 0;
tgtdev->dev_spec.sas_sata_inf.rphy = NULL;
mpi3mr_tgtdev_put(tgtdev);
}The "if (tgtdev) mpi3mr_tgtdev_put(tgtdev)" right before kfree(mr_sas_port) is a second,
independent fix for the same underlying leak that duplicates it. With both present, this path releases the reference twice for what should be a
single release - either double-decrementing a refcount another caller still relies on,
or touching freed memory if this was the last reference.
The fix is to drop the second occurrence and keep the first, since it also clears pend_sas_rphy_add/rphy before releasing the reference, which the duplicate does not:
list_for_each_entry_safe(mr_sas_phy, next, &mr_sas_port->phy_list, port_siblings) {mr_sas_phy->phy_belongs_to_port = 0; list_del(&mr_sas_phy->port_siblings);
}
- if (tgtdev)
- mpi3mr_tgtdev_put(tgtdev);kfree(mr_sas_port);
Thanks,
Ranjan
Quoted 40 lines · Geert Uytterhoeven
Hi Mark,
Quoted 13 lines · Mark Brown
Quoted 11 lines · Geert Uytterhoeven
Quoted 6 lines · Mark Brown
} - if (tgtdev) - mpi3mr_tgtdev_put(tgtdev); kfree(mr_sas_port); return NULL;}
Are you sure this is correct?
Martin's conflict resolution in0b5b2fb484f3bkept theQuoted 6 lines
Quoted 4 lines
if (tgtdev) mpi3mr_tgtdev_put(tgtdev);part.
Dunno. There was another put came in further up the function.
Right. So Martin's resolution looks incorrect, too, as it calls
mpi3mr_tgtdev_put(tgtdev)twice.Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Mark Brown
maintainerQuoted 4 lines · Ranjan Kumar
Hi Geert and Mark,
Author of commit
29e3f0856e854here - confirming Geert is right, this is a genuine double-put, not a style difference.
You probably want comments for this, the code as it is indended looks like a bug.
Martin K. Petersen
maintainerRanjan,
Quoted 3 lines
The fix is to drop the second occurrence and keep the first, since it also clears pend_sas_rphy_add/rphy before releasing the reference, which the duplicate does not:
Been traveling for a couple of days. I'll fix first thing tomorrow.
Signature · 1 line
Martin K. Petersen