mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ranjan Kumar <ranjan.kumar@broadcom.com>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Mark Brown <broonie@kernel.org>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	 Chandrakanth Patil <chandrakanth.patil@broadcom.com>,
	 James Bottomley <James.Bottomley@hansenpartnership.com>,
	 Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	 Linux Next Mailing List <linux-next@vger.kernel.org>,
	"Martin K. Petersen" <mkp@kernel.org>
Subject: Re: linux-next: manual merge of the scsi-mkp tree with the scsi tree
Date: Wed, 30 Sep 2026 15:11:20 +0530	[thread overview]
Message-ID: <CAMFBP8NvykpHj7Dh7TPf-U1f212Av7cppwaS6g-_G4K8ktmr4A@mail.gmail.com> (raw)
In-Reply-To: <CAMuHMdVZpKLzvmRyJ9=jhnT8OhXtTRsHYOAir4S07mzrEa4mkA@mail.gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2575 bytes --]

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


On Wed, Sep 30, 2026 at 12:42 PM Geert Uytterhoeven <geert@linux-m68k.org>
wrote:

> Hi Mark,
>
> On Tue, 29 Sept 2026 at 13:07, Mark Brown <broonie@kernel.org> wrote:
> > On Tue, Sep 29, 2026 at 10:48:09AM +0200, Geert Uytterhoeven wrote:
> > > On Mon, 28 Sept 2026 at 16:23, Mark Brown <broonie@kernel.org> wrote:
> >
> > > >         }
> > > >  -      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.
> >
> > 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 --
> geert@linux-m68k.org
>
> 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
>

[-- Attachment #1.2: Type: text/html, Size: 3457 bytes --]

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 5469 bytes --]

  reply	other threads:[~2026-09-30  9:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 14:15 Mark Brown
2026-09-29  8:48 ` Geert Uytterhoeven
2026-09-29 11:07   ` Mark Brown
2026-09-30  7:12     ` Geert Uytterhoeven
2026-09-30  9:41       ` Ranjan Kumar [this message]
2026-09-30 11:16         ` Mark Brown
2026-10-01  2:19         ` Martin K. Petersen
  -- strict thread matches above, loose matches on Subject: below --
2023-04-03  6:40 Stephen Rothwell
2018-01-25 22:39 Stephen Rothwell
2018-01-25 23:18 ` James Bottomley
2016-11-09  2:57 Stephen Rothwell

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=CAMFBP8NvykpHj7Dh7TPf-U1f212Av7cppwaS6g-_G4K8ktmr4A@mail.gmail.com \
    --to=ranjan.kumar@broadcom.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=broonie@kernel.org \
    --cc=chandrakanth.patil@broadcom.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mkp@kernel.org \
    /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

all inboxes | Powered by JetHome®