Path: csiph.com!news.redatomik.org!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod From: Suman Anna Newsgroups: linux.kernel Subject: Re: [PATCH] rpmsg: rpmsg_core: fix null-ptr dereference for devices without ops Date: Fri, 02 Jun 2017 23:50:01 +0200 Message-ID: References: X-Original-To: Henri Roosen , Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1496440072; bh=wiSdIBFKBqNfu992SPCioiSCZEEAN7i62/bBvR4mF/E=; h=Subject:To:References:CC:From:Date:In-Reply-To; b=wIR8oSCGWFO6SzKU4c5WHFeu3T2kHmL8rFyc2iv2vccH4EzIzIJsLhE2Ww1PIQkhI 2JxYqgLI+wwDo7BfDUQq6qffewJ7eMqcSGFgFSyf0QbCSM6uHKLHoXDyrLUCWy1vq/ ItVpdjPwnp348FgLgs8ZjSyYrPFzg+76oCgNnPa4= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 35 Organization: linux.* mail to news gateway X-Original-Cc: Ohad Ben-Cohen , Bjorn Andersson , open list X-Original-Date: Fri, 2 Jun 2017 16:47:51 -0500 X-Original-Message-ID: <46048bd4-482d-37e8-9701-71754f72ffc2@ti.com> X-Original-References: <1496403321-32234-1-git-send-email-henri.roosen@ginzinger.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1656581 Hi Henri, On 06/02/2017 06:35 AM, Henri Roosen wrote: > A device might not have an ops structure registered. This The rpmsg devices are registered from the respective backends, which are supposed to plug in their ops. What is the scenario where you think these ops might not be populated? We ought to check for NULL ops in rpmsg_register_device in fact to make sure an ops pointer is supplied. regards Suman > patch fixes a null-prt dereference by checking ops before dereferencing > it. > > Signed-off-by: Henri Roosen > --- > drivers/rpmsg/rpmsg_core.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c > index 600f5f9..0c48452 100644 > --- a/drivers/rpmsg/rpmsg_core.c > +++ b/drivers/rpmsg/rpmsg_core.c > @@ -429,7 +429,7 @@ static int rpmsg_dev_probe(struct device *dev) > goto out; > } > > - if (rpdev->ops->announce_create) > + if (rpdev->ops && rpdev->ops->announce_create) > err = rpdev->ops->announce_create(rpdev); > out: > return err; >