Re: [RESEND PATCH 1/2] PM / devfreq: Fix buffer overflow in trans_stat_show

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 04, 2024 at 11:44:54PM +0100, Christian Marangi wrote:
> On Thu, Jan 04, 2024 at 11:19:44PM +0100, Christophe JAILLET wrote:
> > > @@ -1688,7 +1688,7 @@ static ssize_t trans_stat_show(struct device *dev,
> > >   			       struct device_attribute *attr, char *buf)
> > >   {
> > >   	struct devfreq *df = to_devfreq(dev);
> > > -	ssize_t len;
> > > +	ssize_t len = 0;
> > >   	int i, j;
> > >   	unsigned int max_state;
> > > @@ -1697,7 +1697,7 @@ static ssize_t trans_stat_show(struct device *dev,
> > >   	max_state = df->max_state;
> > >   	if (max_state == 0)
> > > -		return sprintf(buf, "Not Supported.\n");
> > > +		return scnprintf(buf, PAGE_SIZE, "Not Supported.\n");
> > 
> > Hi,
> > 
> > maybe using  sysfs_emit_at() could be even cleaner and less verbose?
> >
> 
> If you notice this change is done in the second patch of the series.
> This patch still use this more generic way to permit this to be
> backported on stable kernel. (older kernel doesn't have sysfs_emit_at()
> hence it can't be backported)

All activly supported kernels on the kernel.org front page have
sysfs_emit_at(), so this should not be an issue for anyone.  Just do the
change here at the same time.

thanks,

greg k-h




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux